specdojo 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/specdojo-orchestrator.md +61 -2
- package/CHANGELOG.md +90 -0
- package/README.md +85 -25
- package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +9 -9
- package/dist/{catalog.js → catalog/catalog.js} +10 -10
- package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
- package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
- package/dist/{agent.js → commands/agent.js} +11 -11
- package/dist/{build-command.js → commands/build.js} +2 -2
- package/dist/{init-command.js → commands/init.js} +168 -45
- package/dist/commands/night-orchestrator.js +287 -0
- package/dist/{orchestrator.js → commands/orchestrator.js} +12 -5
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
- package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
- package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
- package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
- package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
- package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
- package/dist/{timeline.js → dashboard/timeline.js} +1 -1
- package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
- package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
- package/dist/{devcontainer-command.js → devcontainer/command.js} +8 -4
- package/dist/devcontainer/scaffold.js +418 -0
- package/dist/{doc-index.js → docs/doc-index.js} +1 -1
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
- package/dist/{index-command.js → docs/index-command.js} +1 -1
- package/dist/docs/template-resolution.js +1 -0
- package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
- package/dist/{exec-agent-config.js → exec/agent-config.js} +92 -5
- package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
- package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
- package/dist/{exec-commands.js → exec/commands.js} +22 -18
- package/dist/{exec-core.js → exec/core.js} +11 -11
- package/dist/{exec-events.js → exec/events.js} +2 -2
- package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
- package/dist/exec/exec.js +2 -0
- package/dist/exec/format.js +1 -0
- package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
- package/dist/{exec-limit.js → exec/limit.js} +93 -12
- package/dist/{exec-parent-validation.js → exec/parent-validation.js} +18 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +29 -2
- package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
- package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
- package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
- package/dist/{exec-plans.js → exec/plans.js} +3 -3
- package/dist/{exec-project.js → exec/project.js} +1 -1
- package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
- package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
- package/dist/{exec-register.js → exec/register.js} +114 -9
- package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
- package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +14 -11
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
- package/dist/{exec-reporter.js → exec/reporter.js} +142 -25
- package/dist/{exec-results.js → exec/results.js} +287 -31
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +35 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +115 -28
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +65 -36
- package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
- package/dist/{exec-run-register-command.js → exec/run/register-command.js} +38 -11
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +63 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +58 -31
- package/dist/exec/run/register-post-review.js +420 -0
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +48 -27
- package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
- package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +119 -24
- package/dist/{exec-run.js → exec/run/run.js} +11 -11
- package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
- package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
- package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
- package/dist/{exec-run-shared.js → exec/run/shared.js} +78 -30
- package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
- package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
- package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
- package/dist/exec/schedule/gantt-chart.js +2 -0
- package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
- package/dist/exec/schedule/index.js +1 -0
- package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
- package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
- package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
- package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
- package/dist/exec/shared.js +63 -0
- package/dist/exec/slot-lock.js +1 -0
- package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
- package/dist/{exec-task-repos.js → exec/task-repos.js} +104 -17
- package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
- package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
- package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
- package/dist/{exec-trial.js → exec/trial.js} +2 -2
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
- package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
- package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
- package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
- package/dist/exec/worktree.js +305 -0
- package/dist/{grade-apply.js → grade/apply.js} +9 -9
- package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
- package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
- package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
- package/dist/{grade-core.js → grade/core.js} +3 -3
- package/dist/grade/grade.js +19 -0
- package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
- package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
- package/dist/{grade-plan.js → grade/plan.js} +5 -5
- package/dist/{grade-result.js → grade/result.js} +5 -94
- package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
- package/dist/{grade-targets.js → grade/targets.js} +11 -8
- package/dist/{job-definition.js → job/definition.js} +25 -6
- package/dist/{job.js → job/job.js} +12 -11
- package/dist/{kata-command.js → kata/command.js} +3 -3
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/{register-core.js → register/core.js} +26 -8
- package/dist/{register-create-commands.js → register/create-commands.js} +171 -8
- package/dist/{register-date.js → register/date.js} +1 -1
- package/dist/register/derivation.js +163 -0
- package/dist/{register-event-merge.js → register/event-merge.js} +44 -3
- package/dist/{register-events.js → register/events.js} +13 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +32 -5
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/{register-migration.js → register/migration.js} +5 -4
- package/dist/{register.js → register/register.js} +32 -27
- package/dist/{register-renumber.js → register/renumber.js} +38 -11
- package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
- package/dist/{register-update.js → register/update.js} +5 -5
- package/dist/{register-views.js → register/views.js} +47 -7
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +3 -3
- package/dist/{routine-definition.js → routine/definition.js} +2 -2
- package/dist/{routine.js → routine/routine.js} +49 -22
- package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +6 -6
- package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
- package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
- package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
- package/dist/shared/agent-types.js +23 -0
- package/dist/shared/artifact-path.js +9 -0
- package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
- package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
- package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
- package/dist/shared/fs.js +30 -0
- package/dist/shared/git.js +346 -0
- package/dist/shared/grade-result.js +94 -0
- package/dist/{package-paths.js → shared/package-paths.js} +3 -3
- package/dist/shared/plan-templates.js +114 -0
- package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +6 -3
- package/dist/shared/random.js +4 -0
- package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
- package/dist/shared/schedule-paths.js +9 -0
- package/dist/{specdojo-config.js → shared/specdojo-config.js} +162 -21
- package/dist/{exec-shared.js → shared/text.js} +4 -135
- package/dist/shared/time.js +28 -0
- package/dist/shared/workspace-scaffold.js +69 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +31 -18
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +3 -2
- package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
- package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
- package/docs/ja/specdojo/exec-templates/xrp-register-post-run-template.md +46 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
- package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +169 -26
- package/docs/ja/specdojo/guides/exec-operation-guide.md +184 -13
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +40 -3
- package/docs/ja/specdojo/guides/quick-start-guide.md +89 -21
- package/docs/ja/specdojo/guides/register-operation-guide.md +44 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +61 -6
- package/docs/ja/specdojo/guides/review-guide.md +1 -1
- package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
- package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
- package/docs/ja/specdojo/guides/waza-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +124 -55
- package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +22 -13
- package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
- package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
- package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
- package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +111 -17
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +28 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
- package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +38 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +5 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +91 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +36 -1
- package/package.json +17 -17
- package/templates/antigravity/README.md +6 -2
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
- package/templates/antigravity/orchestrator.md +61 -2
- package/templates/claude/README.md +27 -3
- package/templates/claude/agents/claude-executor.md +0 -1
- package/templates/claude/agents/claude-reporter.md +2 -1
- package/templates/claude/agents/claude-review-executor.md +0 -1
- package/templates/claude/agents/specdojo-orchestrator.md +61 -2
- package/templates/codex/README.md +40 -4
- package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
- package/templates/codex/orchestrator.md +61 -2
- package/templates/devcontainer/devcontainer.json +5 -2
- package/templates/devcontainer/post-create.sh +15 -7
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +102 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +19 -0
- package/templates/devcontainer/vim/vimrc +37 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +44 -9
- package/templates/opencode/README.md +17 -3
- package/templates/opencode/agents/opencode-executor.md +0 -1
- package/templates/opencode/agents/opencode-reporter.md +2 -1
- package/templates/opencode/agents/opencode-review-executor.md +0 -1
- package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
- package/dist/devcontainer-scaffold.js +0 -165
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec-worktree.js +0 -474
- package/dist/exec.js +0 -2
- package/dist/grade.js +0 -19
- package/templates/claude/agents/claude-expert-review-executor.md +0 -14
- /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
- /package/dist/{catalog-types.js → catalog/types.js} +0 -0
- /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
- /package/dist/{role-types.js → exec/role-types.js} +0 -0
- /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
- /package/dist/{exec-types.js → exec/types.js} +0 -0
- /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
- /package/dist/{register-command-types.js → register/command-types.js} +0 -0
- /package/dist/{review-types.js → review/types.js} +0 -0
- /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
- /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
- /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
- /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
- /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
- /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
- /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
- /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
- /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
- /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
- /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
- /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
- /package/dist/{yaml.js → shared/yaml.js} +0 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
const RECOMMENDED_VSCODE_EXTENSIONS = [
|
|
5
|
+
"mhutchie.git-graph",
|
|
6
|
+
"davidanson.vscode-markdownlint",
|
|
7
|
+
"redhat.vscode-yaml",
|
|
8
|
+
"esbenp.prettier-vscode",
|
|
9
|
+
"unifiedjs.vscode-remark",
|
|
10
|
+
"yzhang.markdown-all-in-one",
|
|
11
|
+
"streetsidesoftware.code-spell-checker",
|
|
12
|
+
"editorconfig.editorconfig",
|
|
13
|
+
"usernamehw.errorlens",
|
|
14
|
+
"tamasfe.even-better-toml",
|
|
15
|
+
];
|
|
16
|
+
const PROVIDER_VSCODE_EXTENSIONS = {
|
|
17
|
+
claude: ["anthropic.claude-code"],
|
|
18
|
+
codex: ["openai.chatgpt"],
|
|
19
|
+
copilot: ["github.copilot", "github.copilot-chat"],
|
|
20
|
+
};
|
|
21
|
+
const RECOMMENDED_VSCODE_SETTINGS = {
|
|
22
|
+
"[markdown]": {
|
|
23
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
24
|
+
"editor.formatOnSave": true,
|
|
25
|
+
},
|
|
26
|
+
"[yaml]": {
|
|
27
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
28
|
+
"editor.formatOnSave": true,
|
|
29
|
+
},
|
|
30
|
+
"yaml.schemas": {
|
|
31
|
+
"./docs/specdojo/schemas/v1/agent-members.schema.yaml": ".specdojo/agent-members.yaml",
|
|
32
|
+
"./docs/specdojo/schemas/v1/exec-defaults.schema.yaml": ".specdojo/exec-defaults.yaml",
|
|
33
|
+
"./docs/specdojo/schemas/v1/job.schema.yaml": "docs/**/jobs/*.yaml",
|
|
34
|
+
"./docs/specdojo/schemas/v1/pm-members.schema.yaml": "docs/**/pm-members.yaml",
|
|
35
|
+
"./docs/specdojo/schemas/v1/pm-review-viewpoints.schema.yaml": "docs/**/pm-review-viewpoints.yaml",
|
|
36
|
+
"./docs/specdojo/schemas/v1/pm-roles.schema.yaml": "docs/**/pm-roles.yaml",
|
|
37
|
+
"./docs/specdojo/schemas/v1/routine.schema.yaml": "docs/**/routines/*.yaml",
|
|
38
|
+
"./docs/specdojo/schemas/v1/sch-defaults.schema.yaml": "docs/**/sch-defaults.yaml",
|
|
39
|
+
"./docs/specdojo/schemas/v1/sch-milestones.schema.yaml": "docs/**/sch-milestones.yaml",
|
|
40
|
+
"./docs/specdojo/schemas/v1/sch-strategy.schema.yaml": "docs/**/sch-strategy-*.yaml",
|
|
41
|
+
"./docs/specdojo/schemas/v1/sch-track.schema.yaml": "docs/**/sch-track-*.yaml",
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
function unique(values) {
|
|
45
|
+
return [...new Set(values)];
|
|
46
|
+
}
|
|
47
|
+
function providerExtensions(providers) {
|
|
48
|
+
return unique(providers.flatMap((provider) => PROVIDER_VSCODE_EXTENSIONS[provider] ?? []));
|
|
49
|
+
}
|
|
50
|
+
function objectValue(value) {
|
|
51
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
52
|
+
? value
|
|
53
|
+
: {};
|
|
54
|
+
}
|
|
55
|
+
async function readExtensionsRecommendations(pathname) {
|
|
56
|
+
if (!existsSync(pathname))
|
|
57
|
+
return { recommendations: [] };
|
|
58
|
+
const parsed = JSON.parse(await readFile(pathname, "utf8"));
|
|
59
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
60
|
+
throw new Error(`Invalid VS Code extensions file: ${pathname}`);
|
|
61
|
+
}
|
|
62
|
+
const result = parsed;
|
|
63
|
+
if (result.recommendations !== undefined && !Array.isArray(result.recommendations)) {
|
|
64
|
+
throw new Error(`Invalid recommendations in VS Code extensions file: ${pathname}`);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
function resolveWorkspaceName(repoRoot, override) {
|
|
69
|
+
const workspaceName = override ?? path.basename(path.dirname(path.resolve(repoRoot)));
|
|
70
|
+
if (workspaceName === "." || workspaceName === ".." || !/^[A-Za-z0-9._-]+$/.test(workspaceName)) {
|
|
71
|
+
throw new Error(`Invalid workspace name: ${JSON.stringify(workspaceName)}. Use only ASCII letters, numbers, dot, underscore, and hyphen.`);
|
|
72
|
+
}
|
|
73
|
+
return workspaceName;
|
|
74
|
+
}
|
|
75
|
+
function repositoryVolumePrefix(repoRoot) {
|
|
76
|
+
const repositoryName = path.basename(path.resolve(repoRoot)).toLowerCase();
|
|
77
|
+
const safeName = repositoryName.replace(/[^a-z0-9_.-]+/g, "-").replace(/^[._-]+|[._-]+$/g, "");
|
|
78
|
+
return safeName || "project";
|
|
79
|
+
}
|
|
80
|
+
function extractPortNumber(value) {
|
|
81
|
+
if (typeof value === "number") {
|
|
82
|
+
return Number.isInteger(value) && value > 0 && value <= 65535 ? value : undefined;
|
|
83
|
+
}
|
|
84
|
+
if (typeof value === "string") {
|
|
85
|
+
const trimmed = value.trim();
|
|
86
|
+
const withoutProto = trimmed.replace(/\/(tcp|udp)$/, "");
|
|
87
|
+
const parts = withoutProto.split(":");
|
|
88
|
+
const portStr = parts.length === 3 ? parts[1] : parts[0];
|
|
89
|
+
const parsed = parseInt(portStr, 10);
|
|
90
|
+
return !isNaN(parsed) && parsed > 0 && parsed <= 65535 ? parsed : undefined;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
export function extractPublishedPorts(devcontainer) {
|
|
95
|
+
const ports = [];
|
|
96
|
+
const addPort = (val) => {
|
|
97
|
+
const port = extractPortNumber(val);
|
|
98
|
+
if (port !== undefined && !ports.includes(port)) {
|
|
99
|
+
ports.push(port);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const appPort = devcontainer.appPort;
|
|
103
|
+
if (Array.isArray(appPort)) {
|
|
104
|
+
for (const p of appPort)
|
|
105
|
+
addPort(p);
|
|
106
|
+
}
|
|
107
|
+
else if (appPort !== undefined) {
|
|
108
|
+
addPort(appPort);
|
|
109
|
+
}
|
|
110
|
+
const forwardPorts = devcontainer.forwardPorts;
|
|
111
|
+
if (Array.isArray(forwardPorts)) {
|
|
112
|
+
for (const p of forwardPorts)
|
|
113
|
+
addPort(p);
|
|
114
|
+
}
|
|
115
|
+
else if (forwardPorts !== undefined) {
|
|
116
|
+
addPort(forwardPorts);
|
|
117
|
+
}
|
|
118
|
+
return ports;
|
|
119
|
+
}
|
|
120
|
+
export function generateSshConfigSample(ports) {
|
|
121
|
+
const lines = [
|
|
122
|
+
"# 接続元端末の ~/.ssh/config 用設定サンプル",
|
|
123
|
+
"# <host> や <user> などのプレースホルダーは実際の接続先環境に合わせて変更してください。",
|
|
124
|
+
"",
|
|
125
|
+
"# 常時稼働ホストへの通常接続用",
|
|
126
|
+
"Host <host>",
|
|
127
|
+
" HostName <host>",
|
|
128
|
+
" User <user>",
|
|
129
|
+
"",
|
|
130
|
+
"# devcontainer 内の tmux セッションへ直接入る接続用",
|
|
131
|
+
"# RemoteCommand は非対話シェルで動くため、接続先端末の ~/.zshrc などの PATH 設定は読み込まれません。",
|
|
132
|
+
"# 接続元から「ssh <host> 'command -v devcontainer'」を実行して Dev Container CLI が見つかるか確認できます。",
|
|
133
|
+
"# 見つからない場合は、ホスト側の ~/bin/specdojo-tmux.sh の node_bin_dir を設定してください。",
|
|
134
|
+
"Host <host>-tmux",
|
|
135
|
+
" HostName <host>",
|
|
136
|
+
" User <user>",
|
|
137
|
+
" RequestTTY force",
|
|
138
|
+
" RemoteCommand ~/bin/specdojo-tmux.sh",
|
|
139
|
+
];
|
|
140
|
+
if (ports.length > 0) {
|
|
141
|
+
for (const port of ports) {
|
|
142
|
+
lines.push(` LocalForward ${port} 127.0.0.1:${port}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
lines.push(" # devcontainer.json の公開ポート(appPort / forwardPorts)に合わせて LocalForward を追加してください。", " # 例: LocalForward 5173 127.0.0.1:5173");
|
|
147
|
+
}
|
|
148
|
+
lines.push("");
|
|
149
|
+
return lines.join("\n");
|
|
150
|
+
}
|
|
151
|
+
export async function runDevcontainerScaffold(opts) {
|
|
152
|
+
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`);
|
|
155
|
+
}
|
|
156
|
+
const recommended = preset === "recommended";
|
|
157
|
+
const effectiveEditors = unique([...editors, ...(recommended ? ["emacs", "vim"] : [])]);
|
|
158
|
+
const effectiveTmux = tmux || recommended;
|
|
159
|
+
const devcontainerDir = path.join(repoRoot, ".devcontainer");
|
|
160
|
+
const workspaceName = resolveWorkspaceName(repoRoot, workspaceNameOverride);
|
|
161
|
+
if (existsSync(devcontainerDir) && !force) {
|
|
162
|
+
if (dryRun) {
|
|
163
|
+
process.stdout.write(`[dry-run] skipped: .devcontainer/ already exists\n`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
process.stdout.write(`Skipped (already exists): .devcontainer/\n`);
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const templateDir = path.join(packageRoot, "templates", "devcontainer");
|
|
171
|
+
if (!existsSync(templateDir)) {
|
|
172
|
+
throw new Error(`Template directory not found: ${templateDir}`);
|
|
173
|
+
}
|
|
174
|
+
// devcontainer.json をパースして改変する
|
|
175
|
+
const devcontainerJsonPath = path.join(templateDir, "devcontainer.json");
|
|
176
|
+
const baseJsonStr = await readFile(devcontainerJsonPath, "utf8");
|
|
177
|
+
const devcontainer = JSON.parse(baseJsonStr);
|
|
178
|
+
const workspaceRoot = `/workspaces/${workspaceName}`;
|
|
179
|
+
devcontainer.workspaceMount = `source=\${localWorkspaceFolder}/..,target=${workspaceRoot},type=bind,consistency=cached`;
|
|
180
|
+
devcontainer.workspaceFolder = `${workspaceRoot}/\${localWorkspaceFolderBasename}`;
|
|
181
|
+
const volumePrefix = repositoryVolumePrefix(repoRoot);
|
|
182
|
+
const volumeName = (name) => `${volumePrefix}-specdojo-${name}`;
|
|
183
|
+
devcontainer.mounts = devcontainer.mounts.map((mount) => mount.replace(/^source=specdojo-/, `source=${volumePrefix}-specdojo-`));
|
|
184
|
+
const postCreateScriptPath = path.join(templateDir, "post-create.sh");
|
|
185
|
+
let postCreateScript = await readFile(postCreateScriptPath, "utf8");
|
|
186
|
+
// options に応じて json と script を改変
|
|
187
|
+
const aptPackages = [];
|
|
188
|
+
const extraScripts = [];
|
|
189
|
+
let emacsInitTemplate;
|
|
190
|
+
let vimrcTemplate;
|
|
191
|
+
if (effectiveTmux) {
|
|
192
|
+
aptPackages.push("tmux");
|
|
193
|
+
}
|
|
194
|
+
if (cron) {
|
|
195
|
+
aptPackages.push("cron");
|
|
196
|
+
devcontainer.postAttachCommand = "sudo service cron start";
|
|
197
|
+
}
|
|
198
|
+
const knownEditors = new Set(["emacs", "vim"]);
|
|
199
|
+
for (const editor of effectiveEditors) {
|
|
200
|
+
if (!knownEditors.has(editor)) {
|
|
201
|
+
process.stdout.write(`Warning: unknown editor "${editor}"\n`);
|
|
202
|
+
}
|
|
203
|
+
if (editor === "emacs") {
|
|
204
|
+
aptPackages.push("emacs-nox", "ripgrep");
|
|
205
|
+
emacsInitTemplate = await readFile(path.join(templateDir, "emacs", "init.el"), "utf8");
|
|
206
|
+
extraScripts.push(`sudo npm install --global \\
|
|
207
|
+
typescript@6.0.3 \\
|
|
208
|
+
typescript-language-server@6.0.1 \\
|
|
209
|
+
yaml-language-server@1.24.0 \\
|
|
210
|
+
bash-language-server@5.8.1
|
|
211
|
+
|
|
212
|
+
MARKSMAN_VERSION="2026-02-08"
|
|
213
|
+
case "$(dpkg --print-architecture)" in
|
|
214
|
+
amd64)
|
|
215
|
+
MARKSMAN_ARCH="x64"
|
|
216
|
+
MARKSMAN_SHA256="be5098e8213219269c47fc0d916a66fa31ce0602ec967475c722260aabf26087"
|
|
217
|
+
;;
|
|
218
|
+
arm64)
|
|
219
|
+
MARKSMAN_ARCH="arm64"
|
|
220
|
+
MARKSMAN_SHA256="db8e124527f7f8048e3e6c91821b9c52ef173d92c01e47d221bf1337afd962fb"
|
|
221
|
+
;;
|
|
222
|
+
*)
|
|
223
|
+
echo "Unsupported architecture for Marksman: $(dpkg --print-architecture)" >&2
|
|
224
|
+
exit 1
|
|
225
|
+
;;
|
|
226
|
+
esac
|
|
227
|
+
curl -fsSL --retry 3 \\
|
|
228
|
+
"https://github.com/artempyanykh/marksman/releases/download/$MARKSMAN_VERSION/marksman-linux-$MARKSMAN_ARCH" \\
|
|
229
|
+
-o /tmp/marksman
|
|
230
|
+
echo "$MARKSMAN_SHA256 /tmp/marksman" | sha256sum -c -
|
|
231
|
+
sudo install -m 0755 /tmp/marksman /usr/local/bin/marksman
|
|
232
|
+
rm -f /tmp/marksman
|
|
233
|
+
|
|
234
|
+
# Keep dotfiles authoritative: install the bundled defaults only when no supported init file exists.
|
|
235
|
+
if [ ! -f "$HOME/.emacs" ] && \\
|
|
236
|
+
[ ! -f "$HOME/.emacs.el" ] && \\
|
|
237
|
+
[ ! -f "$HOME/.emacs.d/init.el" ] && \\
|
|
238
|
+
[ ! -f "$HOME/.config/emacs/init.el" ]; then
|
|
239
|
+
if [ -d "$HOME/.emacs.d" ]; then
|
|
240
|
+
EMACS_INIT="$HOME/.emacs.d/init.el"
|
|
241
|
+
else
|
|
242
|
+
EMACS_INIT="$HOME/.config/emacs/init.el"
|
|
243
|
+
fi
|
|
244
|
+
mkdir -p "$(dirname "$EMACS_INIT")"
|
|
245
|
+
cp .devcontainer/emacs/init.el "$EMACS_INIT"
|
|
246
|
+
echo "Installed Emacs init: $EMACS_INIT"
|
|
247
|
+
fi`);
|
|
248
|
+
}
|
|
249
|
+
else if (editor === "vim") {
|
|
250
|
+
aptPackages.push("vim-nox");
|
|
251
|
+
vimrcTemplate = await readFile(path.join(templateDir, "vim", "vimrc"), "utf8");
|
|
252
|
+
extraScripts.push(`# Keep dotfiles authoritative: install the bundled defaults only when Vim has no user config.
|
|
253
|
+
if [ ! -f "$HOME/.vimrc" ] && [ ! -f "$HOME/.vim/vimrc" ]; then
|
|
254
|
+
cp .devcontainer/vim/vimrc "$HOME/.vimrc"
|
|
255
|
+
echo "Installed Vim config: $HOME/.vimrc"
|
|
256
|
+
fi`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
let vscodeExtensions = [];
|
|
260
|
+
let extensionsFile;
|
|
261
|
+
if (recommended) {
|
|
262
|
+
vscodeExtensions = unique([...RECOMMENDED_VSCODE_EXTENSIONS, ...providerExtensions(providers)]);
|
|
263
|
+
const customizations = (devcontainer.customizations ??= {});
|
|
264
|
+
const vscode = (customizations.vscode ??= {});
|
|
265
|
+
const existingExtensions = Array.isArray(vscode.extensions)
|
|
266
|
+
? vscode.extensions.filter((value) => typeof value === "string")
|
|
267
|
+
: [];
|
|
268
|
+
vscode.extensions = unique([...existingExtensions, ...vscodeExtensions]);
|
|
269
|
+
const existingSettings = objectValue(vscode.settings);
|
|
270
|
+
vscode.settings = {
|
|
271
|
+
...existingSettings,
|
|
272
|
+
"[markdown]": {
|
|
273
|
+
...objectValue(existingSettings["[markdown]"]),
|
|
274
|
+
...RECOMMENDED_VSCODE_SETTINGS["[markdown]"],
|
|
275
|
+
},
|
|
276
|
+
"[yaml]": {
|
|
277
|
+
...objectValue(existingSettings["[yaml]"]),
|
|
278
|
+
...RECOMMENDED_VSCODE_SETTINGS["[yaml]"],
|
|
279
|
+
},
|
|
280
|
+
"yaml.schemas": {
|
|
281
|
+
...objectValue(existingSettings["yaml.schemas"]),
|
|
282
|
+
...RECOMMENDED_VSCODE_SETTINGS["yaml.schemas"],
|
|
283
|
+
},
|
|
284
|
+
};
|
|
285
|
+
const extensionsPath = path.join(repoRoot, ".vscode", "extensions.json");
|
|
286
|
+
extensionsFile = await readExtensionsRecommendations(extensionsPath);
|
|
287
|
+
const existingRecommendations = (extensionsFile.recommendations ?? []);
|
|
288
|
+
extensionsFile.recommendations = unique([
|
|
289
|
+
...existingRecommendations.filter((value) => typeof value === "string"),
|
|
290
|
+
...vscodeExtensions,
|
|
291
|
+
]);
|
|
292
|
+
}
|
|
293
|
+
if (aptPackages.length > 0) {
|
|
294
|
+
devcontainer.features["ghcr.io/rocker-org/devcontainer-features/apt-packages:1"] = {
|
|
295
|
+
packages: aptPackages.join(","),
|
|
296
|
+
upgradePackages: false,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
if (ollama) {
|
|
300
|
+
devcontainer.containerEnv["OLLAMA_BASE_URL"] = "http://host.docker.internal:11434";
|
|
301
|
+
devcontainer.containerEnv["LOCAL_OPENAI_BASE_URL"] = "http://host.docker.internal:11434/v1";
|
|
302
|
+
}
|
|
303
|
+
// providers の処理
|
|
304
|
+
const knownProviders = new Set(["claude", "codex", "opencode", "antigravity"]);
|
|
305
|
+
for (const provider of providers) {
|
|
306
|
+
if (!knownProviders.has(provider)) {
|
|
307
|
+
process.stdout.write(`Warning: unknown provider "${provider}"\n`);
|
|
308
|
+
}
|
|
309
|
+
if (provider === "claude") {
|
|
310
|
+
devcontainer.mounts.push(`source=${volumeName("claude")},target=/home/node/.claude,type=volume`);
|
|
311
|
+
devcontainer.containerEnv["CLAUDE_CONFIG_DIR"] = "/home/node/.claude";
|
|
312
|
+
extraScripts.push('if ! curl -fsSL https://claude.ai/install.sh | bash; then\n echo "Warning: Claude Code installer failed."\nfi');
|
|
313
|
+
}
|
|
314
|
+
else if (provider === "codex") {
|
|
315
|
+
devcontainer.runArgs = devcontainer.runArgs ?? [];
|
|
316
|
+
if (!devcontainer.runArgs.includes("--security-opt=seccomp=unconfined")) {
|
|
317
|
+
devcontainer.runArgs.push("--security-opt=seccomp=unconfined");
|
|
318
|
+
}
|
|
319
|
+
devcontainer.mounts.push(`source=${volumeName("codex")},target=/home/node/.codex,type=volume`);
|
|
320
|
+
extraScripts.push("if dpkg-query -W -f='${Status}' bubblewrap 2>/dev/null | grep -qx 'install ok installed'; then\n if ! sudo apt-get remove -y bubblewrap; then\n echo \"Warning: Failed to remove system bubblewrap; Codex sandbox may not start.\" >&2\n fi\nfi");
|
|
321
|
+
// 本リポジトリの devcontainer と同じく公式の install.sh を使い、失敗したら npm で入れる。
|
|
322
|
+
extraScripts.push('if ! curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh; then\n echo "Warning: Codex installer failed; falling back to npm."\n sudo npm install -g @openai/codex@latest\nfi');
|
|
323
|
+
}
|
|
324
|
+
else if (provider === "opencode") {
|
|
325
|
+
devcontainer.mounts.push(`source=${volumeName("opencode")},target=/home/node/.config/opencode,type=volume`, `source=${volumeName("opencode-data")},target=/home/node/.local/share/opencode,type=volume`);
|
|
326
|
+
devcontainer.containerEnv["OPENCODE_DISABLE_AUTO_UPDATE"] = "1";
|
|
327
|
+
// 本リポジトリで設定を確かめている opencode の npm パッケージ(opencode-ai)を使う。
|
|
328
|
+
extraScripts.push("sudo npm install -g opencode-ai@latest");
|
|
329
|
+
}
|
|
330
|
+
else if (provider === "antigravity") {
|
|
331
|
+
devcontainer.mounts.push(`source=${volumeName("antigravity")},target=/home/node/.config/antigravity,type=volume`);
|
|
332
|
+
extraScripts.push('if ! curl -fsSL https://antigravity.google/cli/install.sh | bash; then\n echo "Warning: Antigravity CLI installer failed."\nfi');
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (extraScripts.length > 0) {
|
|
336
|
+
postCreateScript = postCreateScript.replace("npm install", extraScripts.join("\n\n") + "\n\nnpm install");
|
|
337
|
+
}
|
|
338
|
+
const specdojoTmuxTemplatePath = path.join(templateDir, "remote-host", "specdojo-tmux.sh.sample");
|
|
339
|
+
let specdojoTmuxScript = await readFile(specdojoTmuxTemplatePath, "utf8");
|
|
340
|
+
const remoteUser = typeof devcontainer.remoteUser === "string" && devcontainer.remoteUser.trim()
|
|
341
|
+
? devcontainer.remoteUser.trim()
|
|
342
|
+
: "node";
|
|
343
|
+
const userLocalBin = `/home/${remoteUser}/.local/bin`;
|
|
344
|
+
const existingRemoteEnv = objectValue(devcontainer.remoteEnv);
|
|
345
|
+
const existingPath = typeof existingRemoteEnv.PATH === "string" ? existingRemoteEnv.PATH : undefined;
|
|
346
|
+
let remotePath;
|
|
347
|
+
if (existingPath) {
|
|
348
|
+
if (existingPath === "/home/node/.local/bin:${containerEnv:PATH}") {
|
|
349
|
+
remotePath = `${userLocalBin}:\${containerEnv:PATH}`;
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
const parts = existingPath.split(":");
|
|
353
|
+
remotePath = parts.includes(userLocalBin) ? existingPath : `${userLocalBin}:${existingPath}`;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
remotePath = `${userLocalBin}:\${containerEnv:PATH}`;
|
|
358
|
+
}
|
|
359
|
+
devcontainer.remoteEnv = {
|
|
360
|
+
...existingRemoteEnv,
|
|
361
|
+
PATH: remotePath,
|
|
362
|
+
};
|
|
363
|
+
specdojoTmuxScript = specdojoTmuxScript.replace('container_user="node"', `container_user="${remoteUser}"`);
|
|
364
|
+
const publishedPorts = extractPublishedPorts(devcontainer);
|
|
365
|
+
const sshConfigScript = generateSshConfigSample(publishedPorts);
|
|
366
|
+
if (dryRun) {
|
|
367
|
+
process.stdout.write(`[dry-run] would write: .devcontainer/devcontainer.json\n`);
|
|
368
|
+
process.stdout.write(`[dry-run] would write: .devcontainer/post-create.sh\n`);
|
|
369
|
+
if (emacsInitTemplate !== undefined) {
|
|
370
|
+
process.stdout.write(`[dry-run] would write: .devcontainer/emacs/init.el\n`);
|
|
371
|
+
}
|
|
372
|
+
if (vimrcTemplate !== undefined) {
|
|
373
|
+
process.stdout.write(`[dry-run] would write: .devcontainer/vim/vimrc\n`);
|
|
374
|
+
}
|
|
375
|
+
if (extensionsFile !== undefined) {
|
|
376
|
+
process.stdout.write(`[dry-run] would write: .vscode/extensions.json\n`);
|
|
377
|
+
}
|
|
378
|
+
process.stdout.write(`[dry-run] would write: .devcontainer/remote-host/specdojo-tmux.sh.sample\n`);
|
|
379
|
+
process.stdout.write(`[dry-run] would write: .devcontainer/remote-host/ssh-config.sample\n`);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
await mkdir(devcontainerDir, { recursive: true });
|
|
383
|
+
await writeFile(path.join(devcontainerDir, "devcontainer.json"), JSON.stringify(devcontainer, null, 2) + "\n", "utf8");
|
|
384
|
+
await writeFile(path.join(devcontainerDir, "post-create.sh"), postCreateScript, "utf8");
|
|
385
|
+
if (emacsInitTemplate !== undefined) {
|
|
386
|
+
await mkdir(path.join(devcontainerDir, "emacs"), { recursive: true });
|
|
387
|
+
await writeFile(path.join(devcontainerDir, "emacs", "init.el"), emacsInitTemplate, "utf8");
|
|
388
|
+
}
|
|
389
|
+
if (vimrcTemplate !== undefined) {
|
|
390
|
+
await mkdir(path.join(devcontainerDir, "vim"), { recursive: true });
|
|
391
|
+
await writeFile(path.join(devcontainerDir, "vim", "vimrc"), vimrcTemplate, "utf8");
|
|
392
|
+
}
|
|
393
|
+
if (extensionsFile !== undefined) {
|
|
394
|
+
await mkdir(path.join(repoRoot, ".vscode"), { recursive: true });
|
|
395
|
+
await writeFile(path.join(repoRoot, ".vscode", "extensions.json"), `${JSON.stringify(extensionsFile, null, 2)}\n`, "utf8");
|
|
396
|
+
}
|
|
397
|
+
const remoteHostDir = path.join(devcontainerDir, "remote-host");
|
|
398
|
+
await mkdir(remoteHostDir, { recursive: true });
|
|
399
|
+
await writeFile(path.join(remoteHostDir, "specdojo-tmux.sh.sample"), specdojoTmuxScript, "utf8");
|
|
400
|
+
await writeFile(path.join(remoteHostDir, "ssh-config.sample"), sshConfigScript, "utf8");
|
|
401
|
+
process.stdout.write(`Written: .devcontainer/devcontainer.json\n`);
|
|
402
|
+
process.stdout.write(`Written: .devcontainer/post-create.sh\n`);
|
|
403
|
+
if (emacsInitTemplate !== undefined) {
|
|
404
|
+
process.stdout.write(`Written: .devcontainer/emacs/init.el\n`);
|
|
405
|
+
}
|
|
406
|
+
if (vimrcTemplate !== undefined) {
|
|
407
|
+
process.stdout.write(`Written: .devcontainer/vim/vimrc\n`);
|
|
408
|
+
}
|
|
409
|
+
if (extensionsFile !== undefined) {
|
|
410
|
+
process.stdout.write(`Written: .vscode/extensions.json\n`);
|
|
411
|
+
}
|
|
412
|
+
process.stdout.write(`Written: .devcontainer/remote-host/specdojo-tmux.sh.sample\n`);
|
|
413
|
+
process.stdout.write(`Written: .devcontainer/remote-host/ssh-config.sample\n`);
|
|
414
|
+
process.stdout.write("Next steps:\n" +
|
|
415
|
+
" 1. Commit the scaffolded files.\n" +
|
|
416
|
+
" 2. Open this directory in a Dev Container (VS Code or compatible editor).\n" +
|
|
417
|
+
" 3. Remote host: copy .devcontainer/remote-host/specdojo-tmux.sh.sample to the host (e.g. ~/bin/) and merge ssh-config.sample into ~/.ssh/config on your client.\n");
|
|
418
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, relative, resolve } from "node:path";
|
|
3
|
-
import { load } from "
|
|
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
6
|
const SKIP_DIRS = new Set(["node_modules", "dist", ".vitepress", "out"]);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// 対象は Markdown frontmatter のみ。独立 YAML データファイル(dct-*.yaml / pm-*.yaml /
|
|
6
6
|
// sch-*.yaml など)は名前空間化しないため、本モジュールは使わない。
|
|
7
|
-
import { load } from "
|
|
7
|
+
import { load } from "../shared/yaml.js";
|
|
8
8
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
9
9
|
function specdojoFromBlock(block) {
|
|
10
10
|
let parsed;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
-
import { loadEnv, specdojoRootDir } from "
|
|
3
|
+
import { loadEnv, specdojoRootDir } from "../shared/specdojo-config.js";
|
|
4
4
|
import { assertControlGeneratedIndexes, buildDocIndex, lookupDocIndex, replaceDocIndexRefs, } from "./doc-index.js";
|
|
5
5
|
function printCommandError(error) {
|
|
6
6
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../shared/template-resolution.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readdirSync, readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { load } from "
|
|
4
|
+
import { load } from "../shared/yaml.js";
|
|
5
5
|
// PJR-H220 / PJR-VJP8: 観点の document_kinds は rulebook ID の列挙で宣言する。rulebook を
|
|
6
6
|
// 追加したときに観点ごとの扱いの判断が漏れないよう、include / exclude / confirmed_default の
|
|
7
7
|
// どれにも載っていない rulebook を一覧にする。confirmed_default は判断の記録であり、適用判定
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
import { loadEnv, specdojoRootDir } from "
|
|
2
|
+
import { loadEnv, specdojoRootDir } from "../shared/specdojo-config.js";
|
|
3
3
|
import { buildYamlPages } from "./yaml-pages.js";
|
|
4
4
|
function printCommandError(error) {
|
|
5
5
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, posix } from "node:path";
|
|
3
|
-
import { dump, load } from "
|
|
3
|
+
import { dump, load } from "../shared/yaml.js";
|
|
4
4
|
import { collectDocIndexEntries } from "./doc-index.js";
|
|
5
|
-
import { isDctTemplateCatalog, renderCatalogTemplateBody } from "
|
|
5
|
+
import { isDctTemplateCatalog, renderCatalogTemplateBody } from "../shared/catalog-render.js";
|
|
6
6
|
// YAML は VitePress のページにならないため、doc-index に載っている YAML ごとに
|
|
7
7
|
// 同階層の generated/<name>.md へ表示用ページ(本文を yaml コードブロックで埋め込んだ
|
|
8
8
|
// Markdown)を生成する。wikilink・frontmatter リンクはこのページへ解決される。
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { listFilesRecursive, readYaml } from "./
|
|
4
|
-
import { acquirePoolSlot, releaseLock } from "./
|
|
5
|
-
import { specdojoRootDir, } from "
|
|
6
|
-
import { resolveParentValidationConcurrency, resolveParentValidationDefinitions, } from "./
|
|
2
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
3
|
+
import { listFilesRecursive, readYaml } from "./shared.js";
|
|
4
|
+
import { acquirePoolSlot, releaseLock } from "./slot-lock.js";
|
|
5
|
+
import { getProjectExecutionPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
6
|
+
import { resolveParentValidationConcurrency, resolveParentValidationDefinitions, } from "./parent-validation.js";
|
|
7
7
|
const PLACEHOLDER_PATTERN = /\{([a-z][a-z0-9_]*)\}/g;
|
|
8
8
|
const BUILTIN_VARIABLE_NAMES = new Set(["nickname", "mode", "proficiency"]);
|
|
9
9
|
// Mirror of the nickname pattern in docs/specdojo/schemas/v1/agent-members.schema.yaml.
|
|
@@ -53,6 +53,10 @@ function buildCommandVariables(provider, member, params) {
|
|
|
53
53
|
variables.set(key, value);
|
|
54
54
|
for (const [key, value] of Object.entries(byNickname ?? {}))
|
|
55
55
|
variables.set(key, value);
|
|
56
|
+
// A concrete member's model is the source of truth. Legacy members without model keep using
|
|
57
|
+
// command_params, so existing one-level rosters and templates remain compatible.
|
|
58
|
+
if (member.model)
|
|
59
|
+
variables.set("model", member.model);
|
|
56
60
|
return variables;
|
|
57
61
|
}
|
|
58
62
|
// Resolve the shell command that launches a member's agent. Returns undefined when the
|
|
@@ -84,10 +88,33 @@ export function resolveRateLimitDetection(config, provider) {
|
|
|
84
88
|
const override = provider ? config.providers?.[provider]?.rate_limit_detection : undefined;
|
|
85
89
|
return override ?? config.rate_limit_detection;
|
|
86
90
|
}
|
|
91
|
+
export function resolveConnectionErrorDetection(config, provider) {
|
|
92
|
+
const override = provider ? config.providers?.[provider]?.connection_error_detection : undefined;
|
|
93
|
+
return override ?? config.connection_error_detection;
|
|
94
|
+
}
|
|
87
95
|
export function resolveRateLimitPolicy(config, provider) {
|
|
88
96
|
const override = provider ? config.providers?.[provider]?.rate_limit_policy : undefined;
|
|
89
97
|
return override ?? config.rate_limit_policy;
|
|
90
98
|
}
|
|
99
|
+
export const DEFAULT_PINNED_RATE_LIMIT_MAX_WAIT_SECONDS = 8 * 60 * 60;
|
|
100
|
+
/** Resolve and validate the policy used only for agents selected by nickname. */
|
|
101
|
+
export function resolvePinnedRateLimitPolicy(config, provider) {
|
|
102
|
+
const pinned = resolveRateLimitPolicy(config, provider)?.pinned;
|
|
103
|
+
const action = pinned?.action ?? "stop";
|
|
104
|
+
if (action !== "stop" && action !== "wait" && action !== "fallback") {
|
|
105
|
+
throw new Error(`rate_limit_policy.pinned.action in exec-defaults must be "stop", "wait", or "fallback": ${String(action)}`);
|
|
106
|
+
}
|
|
107
|
+
const maxWaitSeconds = pinned?.max_wait_seconds ?? DEFAULT_PINNED_RATE_LIMIT_MAX_WAIT_SECONDS;
|
|
108
|
+
if (!Number.isFinite(maxWaitSeconds) || maxWaitSeconds < 0) {
|
|
109
|
+
throw new Error(`rate_limit_policy.pinned.max_wait_seconds in exec-defaults must be a non-negative number: ${String(maxWaitSeconds)}`);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
action,
|
|
113
|
+
maxWaitSeconds,
|
|
114
|
+
...(pinned?.fallback_executor_by ? { fallbackExecutorBy: pinned.fallback_executor_by } : {}),
|
|
115
|
+
...(pinned?.fallback_reporter_by ? { fallbackReporterBy: pinned.fallback_reporter_by } : {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
91
118
|
// Resolve a provider's concurrency cap, validating the YAML-sourced value. A missing,
|
|
92
119
|
// non-integer, or non-positive value means "no limit" (returns undefined).
|
|
93
120
|
export function resolveMaxConcurrency(config, provider) {
|
|
@@ -128,6 +155,7 @@ export function providerSlotPoolPath(lockRoot, provider) {
|
|
|
128
155
|
}
|
|
129
156
|
export const DEFAULT_MAX_CONCURRENT_RUNS = 4;
|
|
130
157
|
export const DEFAULT_REGISTER_EXECUTION = "in-place";
|
|
158
|
+
export const DEFAULT_REGISTER_POST_REVIEW = false;
|
|
131
159
|
// Preserve the historical default for repositories that have not opted into worktree execution.
|
|
132
160
|
// Invalid YAML-sourced values are rejected instead of silently changing where agents write.
|
|
133
161
|
export function resolveRegisterExecution(config) {
|
|
@@ -139,6 +167,15 @@ export function resolveRegisterExecution(config) {
|
|
|
139
167
|
}
|
|
140
168
|
return raw;
|
|
141
169
|
}
|
|
170
|
+
export function resolveRegisterPostReview(config) {
|
|
171
|
+
const raw = config.run?.register_post_review;
|
|
172
|
+
if (raw === undefined)
|
|
173
|
+
return DEFAULT_REGISTER_POST_REVIEW;
|
|
174
|
+
if (typeof raw !== "boolean") {
|
|
175
|
+
throw new Error(`run.register_post_review in exec-defaults must be true or false: ${String(raw)}`);
|
|
176
|
+
}
|
|
177
|
+
return raw;
|
|
178
|
+
}
|
|
142
179
|
// Resolve how many `exec run` processes may run at once for one project. Invalid values fall back
|
|
143
180
|
// to the default so a typo cannot silently disable the busy guard.
|
|
144
181
|
export function resolveMaxConcurrentRuns(config) {
|
|
@@ -246,6 +283,37 @@ function loadLegacyRateLimitPolicy(executionPath) {
|
|
|
246
283
|
}
|
|
247
284
|
return undefined;
|
|
248
285
|
}
|
|
286
|
+
function projectParentValidations(executionPath) {
|
|
287
|
+
if (!executionPath)
|
|
288
|
+
return [];
|
|
289
|
+
const { config } = loadConfig();
|
|
290
|
+
if (!config)
|
|
291
|
+
return [];
|
|
292
|
+
const rootDir = specdojoRootDir();
|
|
293
|
+
const targetExecutionPath = resolve(executionPath);
|
|
294
|
+
const normalizedTarget = targetExecutionPath.replaceAll("\\", "/");
|
|
295
|
+
for (const [projectId, project] of Object.entries(config.projects)) {
|
|
296
|
+
const configuredExecutionPath = getProjectExecutionPath(project);
|
|
297
|
+
const resolvedExecutionPath = resolve(rootDir, configuredExecutionPath);
|
|
298
|
+
const normalizedConfigured = configuredExecutionPath.replaceAll("\\", "/");
|
|
299
|
+
// Job review loads defaults before changing cwd to its worktree. In that case loadConfig()
|
|
300
|
+
// resolves the main checkout while executionPath already points into the worktree; the
|
|
301
|
+
// repository-relative project path remains the same suffix in both locations.
|
|
302
|
+
const isProjectWorktreePath = !isAbsolute(configuredExecutionPath) &&
|
|
303
|
+
normalizedTarget.endsWith(`/${normalizedConfigured.replace(/^\.\//, "")}`);
|
|
304
|
+
if (resolvedExecutionPath !== targetExecutionPath && !isProjectWorktreePath)
|
|
305
|
+
continue;
|
|
306
|
+
const entries = project.run
|
|
307
|
+
?.parent_validations;
|
|
308
|
+
if (entries === undefined)
|
|
309
|
+
return [];
|
|
310
|
+
if (!Array.isArray(entries)) {
|
|
311
|
+
throw new Error(`Invalid .specdojo/specdojo.config.json: projects.${projectId}.run.parent_validations must be an array`);
|
|
312
|
+
}
|
|
313
|
+
return entries;
|
|
314
|
+
}
|
|
315
|
+
return [];
|
|
316
|
+
}
|
|
249
317
|
export function loadExecDefaultsConfig(configPath, executionPath) {
|
|
250
318
|
const path = configPath ?? defaultExecDefaultsPath();
|
|
251
319
|
let defaults = {};
|
|
@@ -263,8 +331,27 @@ export function loadExecDefaultsConfig(configPath, executionPath) {
|
|
|
263
331
|
if (legacyPolicy)
|
|
264
332
|
defaults.rate_limit_policy = legacyPolicy;
|
|
265
333
|
}
|
|
334
|
+
const additionalParentValidations = projectParentValidations(executionPath);
|
|
335
|
+
if (additionalParentValidations.length > 0) {
|
|
336
|
+
defaults = {
|
|
337
|
+
...defaults,
|
|
338
|
+
pipeline: {
|
|
339
|
+
...defaults.pipeline,
|
|
340
|
+
parent_validations: [
|
|
341
|
+
...(defaults.pipeline?.parent_validations ?? []),
|
|
342
|
+
...additionalParentValidations,
|
|
343
|
+
],
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
}
|
|
266
347
|
resolveParentValidationDefinitions(defaults.pipeline?.parent_validations);
|
|
267
348
|
resolveParentValidationConcurrency(defaults.pipeline?.parent_validation_concurrency);
|
|
268
349
|
resolveRegisterExecution(defaults);
|
|
350
|
+
resolvePinnedRateLimitPolicy(defaults);
|
|
351
|
+
for (const provider of Object.keys(defaults.providers ?? {})) {
|
|
352
|
+
if (defaults.providers?.[provider]?.rate_limit_policy) {
|
|
353
|
+
resolvePinnedRateLimitPolicy(defaults, provider);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
269
356
|
return defaults;
|
|
270
357
|
}
|
|
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync } from "node:fs";
|
|
4
4
|
import { join, relative, sep } from "node:path";
|
|
5
|
-
import { gitEnvironment, gitResult } from "./
|
|
5
|
+
import { gitEnvironment, gitResult } from "./worktree.js";
|
|
6
6
|
// PJR-3S8Q で agent の書き込み対象外とした、親 runner / hook / CI の実行内容を
|
|
7
7
|
// 変えられる設定パス。provider 設定から注入できない固定定義として CLI 側に持つ。
|
|
8
8
|
export const PROTECTED_DIRECTORY_PREFIXES = [
|