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
|
@@ -3,7 +3,8 @@ import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "n
|
|
|
3
3
|
import dotenv from "dotenv";
|
|
4
4
|
import { dump, load } from "./yaml.js";
|
|
5
5
|
import Ajv2020Module from "ajv/dist/2020.js";
|
|
6
|
-
import { runProviderScaffold, specdojoPackageRootDir } from "./
|
|
6
|
+
import { runProviderScaffold, specdojoPackageRootDir } from "./provider-scaffold.js";
|
|
7
|
+
import { runWorkspaceScaffold } from "./workspace-scaffold.js";
|
|
7
8
|
import { ensureGitignore, formatGitignoreReport, gitignorePatternsForLayouts, } from "./specdojo-gitignore.js";
|
|
8
9
|
/** Default IANA time zone for register date derivation when run.register_date_timezone is unset. */
|
|
9
10
|
export const DEFAULT_REGISTER_DATE_TIMEZONE = "UTC";
|
|
@@ -56,6 +57,67 @@ export function resolveRepoRoot(rootDir, repo) {
|
|
|
56
57
|
return resolve(rootDir, repo.path);
|
|
57
58
|
}
|
|
58
59
|
export const DEFAULT_PROJECT_CONTEXT = ["prj-overview"];
|
|
60
|
+
// Register events also have a small set of product-owned actors that do not represent a
|
|
61
|
+
// roster member. Keep this list closed: accepting arbitrary strings would make the audit log
|
|
62
|
+
// impossible to trace back to either a person, an agent, or a known SpecDojo component.
|
|
63
|
+
export const RESERVED_REGISTER_ACTORS = [
|
|
64
|
+
"SpecDojo",
|
|
65
|
+
"specdojo-orchestrator",
|
|
66
|
+
"night-orchestrator",
|
|
67
|
+
];
|
|
68
|
+
// Resolve either a concrete agent nickname or a backward-compatible alias to the concrete
|
|
69
|
+
// member. Alias validity is checked while loading the roster, but keep the traversal guarded so
|
|
70
|
+
// callers and tests that construct a roster directly cannot loop forever on malformed input.
|
|
71
|
+
export function resolveAgentMember(roster, nickname) {
|
|
72
|
+
if (!roster)
|
|
73
|
+
return undefined;
|
|
74
|
+
const members = new Map(roster.members
|
|
75
|
+
.filter((member) => member.type === "agent")
|
|
76
|
+
.map((member) => [member.nickname, member]));
|
|
77
|
+
const direct = members.get(nickname);
|
|
78
|
+
if (direct)
|
|
79
|
+
return direct;
|
|
80
|
+
const aliases = new Map((roster.aliases ?? []).map((alias) => [alias.nickname, alias.alias_of]));
|
|
81
|
+
const seen = new Set();
|
|
82
|
+
let current = nickname;
|
|
83
|
+
while (!seen.has(current)) {
|
|
84
|
+
seen.add(current);
|
|
85
|
+
const target = aliases.get(current);
|
|
86
|
+
if (!target)
|
|
87
|
+
return undefined;
|
|
88
|
+
const member = members.get(target);
|
|
89
|
+
if (member)
|
|
90
|
+
return member.disabled ? undefined : member;
|
|
91
|
+
current = target;
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
export function resolveRegisterActor(actor, roster) {
|
|
96
|
+
const normalized = actor.trim();
|
|
97
|
+
if (!normalized) {
|
|
98
|
+
throw new Error("Register event actor must not be empty");
|
|
99
|
+
}
|
|
100
|
+
if (RESERVED_REGISTER_ACTORS.includes(normalized))
|
|
101
|
+
return normalized;
|
|
102
|
+
const agent = resolveAgentMember(roster, normalized);
|
|
103
|
+
if (agent)
|
|
104
|
+
return agent.nickname;
|
|
105
|
+
const humans = roster?.members.filter((member) => member.type === "human" && member.nickname === normalized) ??
|
|
106
|
+
[];
|
|
107
|
+
if (humans.length === 1)
|
|
108
|
+
return humans[0].nickname;
|
|
109
|
+
if (humans.length > 1) {
|
|
110
|
+
throw new Error(`Duplicate human actor nickname in members_path: ${normalized}`);
|
|
111
|
+
}
|
|
112
|
+
const rosterNames = [
|
|
113
|
+
...(roster?.members.map((member) => member.nickname) ?? []),
|
|
114
|
+
...(roster?.aliases?.map((alias) => alias.nickname) ?? []),
|
|
115
|
+
];
|
|
116
|
+
const accepted = [...new Set([...rosterNames, ...RESERVED_REGISTER_ACTORS])].sort();
|
|
117
|
+
throw new Error(`Unknown register actor: "${normalized}". Use a human nickname from members_path, ` +
|
|
118
|
+
`an agent nickname or alias from agent_members_path, or a reserved actor: ` +
|
|
119
|
+
accepted.join(", "));
|
|
120
|
+
}
|
|
59
121
|
export const DEFAULT_AGENT_MEMBERS_PATH = ".specdojo/agent-members.yaml";
|
|
60
122
|
function findUpward(startDir, name) {
|
|
61
123
|
let currentDir = resolve(startDir);
|
|
@@ -82,13 +144,13 @@ export function specdojoRootDir() {
|
|
|
82
144
|
export function defaultWorktreeBase(rootDir = specdojoRootDir()) {
|
|
83
145
|
return `../${basename(resolve(rootDir))}-worktrees`;
|
|
84
146
|
}
|
|
85
|
-
export function loadEnv() {
|
|
147
|
+
export function loadEnv(rootDir = specdojoRootDir()) {
|
|
86
148
|
// Load .env from the repository root if present.
|
|
87
149
|
// Safe if missing.
|
|
88
|
-
dotenv.config({ path: resolve(
|
|
150
|
+
dotenv.config({ path: resolve(rootDir, ".env"), quiet: true });
|
|
89
151
|
}
|
|
90
|
-
export function defaultConfigPath() {
|
|
91
|
-
return join(
|
|
152
|
+
export function defaultConfigPath(rootDir = specdojoRootDir()) {
|
|
153
|
+
return join(resolve(rootDir), ".specdojo", "specdojo.config.json");
|
|
92
154
|
}
|
|
93
155
|
// Join a project document path with the project's base_path, returning a repo-root-relative path.
|
|
94
156
|
// An empty/undefined base_path leaves the path unchanged (full backward compatibility).
|
|
@@ -313,6 +375,7 @@ export function loadMemberRoster(baseDir, project) {
|
|
|
313
375
|
throw new Error(`Invalid agent members file: ${agentFullPath}: human '${human.nickname ?? "<unknown>"}' is not allowed`);
|
|
314
376
|
}
|
|
315
377
|
validateMemberFile("agent-members.schema.yaml", agentFullPath, agentRoster);
|
|
378
|
+
validateAgentAliases(agentFullPath, agentRoster);
|
|
316
379
|
}
|
|
317
380
|
if (!humanRoster && !agentRoster)
|
|
318
381
|
return null;
|
|
@@ -328,10 +391,64 @@ export function loadMemberRoster(baseDir, project) {
|
|
|
328
391
|
}
|
|
329
392
|
seen.set(member.nickname, source);
|
|
330
393
|
}
|
|
394
|
+
for (const alias of agentRoster?.aliases ?? []) {
|
|
395
|
+
const previousSource = seen.get(alias.nickname);
|
|
396
|
+
if (previousSource) {
|
|
397
|
+
throw new Error(`Duplicate member or alias nickname '${alias.nickname}' across ${previousSource} and ${agentFullPath}`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
331
400
|
const members = membersWithSources.map(({ member }) => member);
|
|
401
|
+
const aliases = agentRoster?.aliases;
|
|
332
402
|
if (humanRoster)
|
|
333
|
-
return { ...humanRoster, members };
|
|
334
|
-
return { version: agentRoster?.version ?? 1, members };
|
|
403
|
+
return { ...humanRoster, members, ...(aliases ? { aliases } : {}) };
|
|
404
|
+
return { version: agentRoster?.version ?? 1, members, ...(aliases ? { aliases } : {}) };
|
|
405
|
+
}
|
|
406
|
+
function validateAgentAliases(path, roster) {
|
|
407
|
+
const members = new Map();
|
|
408
|
+
for (const member of roster.members) {
|
|
409
|
+
if (members.has(member.nickname)) {
|
|
410
|
+
throw new Error(`Invalid agent members file: ${path}: duplicate member '${member.nickname}'`);
|
|
411
|
+
}
|
|
412
|
+
members.set(member.nickname, member);
|
|
413
|
+
}
|
|
414
|
+
const aliases = new Map();
|
|
415
|
+
for (const alias of roster.aliases ?? []) {
|
|
416
|
+
if (members.has(alias.nickname)) {
|
|
417
|
+
throw new Error(`Invalid agent alias '${alias.nickname}' in ${path}: name conflicts with a member`);
|
|
418
|
+
}
|
|
419
|
+
if (aliases.has(alias.nickname)) {
|
|
420
|
+
throw new Error(`Invalid agent alias '${alias.nickname}' in ${path}: duplicate alias name`);
|
|
421
|
+
}
|
|
422
|
+
aliases.set(alias.nickname, alias.alias_of);
|
|
423
|
+
}
|
|
424
|
+
const resolved = new Set();
|
|
425
|
+
const resolveAlias = (nickname, chain) => {
|
|
426
|
+
if (resolved.has(nickname))
|
|
427
|
+
return;
|
|
428
|
+
const cycleStart = chain.indexOf(nickname);
|
|
429
|
+
if (cycleStart >= 0) {
|
|
430
|
+
const cycle = [...chain.slice(cycleStart), nickname].join(" -> ");
|
|
431
|
+
throw new Error(`Invalid agent alias '${nickname}' in ${path}: alias cycle ${cycle}`);
|
|
432
|
+
}
|
|
433
|
+
const target = aliases.get(nickname);
|
|
434
|
+
if (!target)
|
|
435
|
+
return;
|
|
436
|
+
const member = members.get(target);
|
|
437
|
+
if (member) {
|
|
438
|
+
if (member.disabled) {
|
|
439
|
+
throw new Error(`Invalid agent alias '${nickname}' in ${path}: alias_of '${target}' resolves to a disabled member`);
|
|
440
|
+
}
|
|
441
|
+
resolved.add(nickname);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
if (!aliases.has(target)) {
|
|
445
|
+
throw new Error(`Invalid agent alias '${nickname}' in ${path}: alias_of '${target}' does not resolve to a member`);
|
|
446
|
+
}
|
|
447
|
+
resolveAlias(target, [...chain, nickname]);
|
|
448
|
+
resolved.add(nickname);
|
|
449
|
+
};
|
|
450
|
+
for (const nickname of aliases.keys())
|
|
451
|
+
resolveAlias(nickname, []);
|
|
335
452
|
}
|
|
336
453
|
const Ajv2020 = Ajv2020Module.default;
|
|
337
454
|
const memberSchemaValidators = new Map();
|
|
@@ -425,9 +542,9 @@ function isValidProjectConfig(project) {
|
|
|
425
542
|
}
|
|
426
543
|
return true;
|
|
427
544
|
}
|
|
428
|
-
export function loadConfig() {
|
|
429
|
-
loadEnv();
|
|
430
|
-
const configPath = defaultConfigPath();
|
|
545
|
+
export function loadConfig(configRootDir = specdojoRootDir()) {
|
|
546
|
+
loadEnv(configRootDir);
|
|
547
|
+
const configPath = defaultConfigPath(configRootDir);
|
|
431
548
|
if (!existsSync(configPath)) {
|
|
432
549
|
return { configPath, config: null };
|
|
433
550
|
}
|
|
@@ -559,20 +676,38 @@ export function registerConfigCommands(program) {
|
|
|
559
676
|
});
|
|
560
677
|
cfg
|
|
561
678
|
.command("scaffold")
|
|
562
|
-
.description("Scaffold agent/settings templates for a provider")
|
|
563
|
-
.
|
|
679
|
+
.description("Scaffold agent/settings templates for a provider or VS Code multi-root workspace")
|
|
680
|
+
.option("--provider <name>", "Provider template to copy (antigravity|claude|codex|copilot|opencode)")
|
|
681
|
+
.option("--workspace", "Generate VS Code multi-root workspace (<project-id>.code-workspace) from repos config", false)
|
|
682
|
+
.option("--project <id>", "Target project ID for workspace scaffolding (defaults to current_project)")
|
|
564
683
|
.option("--force", "Overwrite existing files", false)
|
|
565
684
|
.option("--dry-run", "Show planned files without writing", false)
|
|
566
685
|
.option("--global", "Merge provider permissions into user-level settings (currently antigravity only)", false)
|
|
567
686
|
.action(async (opts) => {
|
|
568
687
|
try {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
688
|
+
if (!opts.provider && !opts.workspace) {
|
|
689
|
+
throw new Error("Specify --provider <name> or --workspace to scaffold.");
|
|
690
|
+
}
|
|
691
|
+
if (opts.global && !opts.provider) {
|
|
692
|
+
throw new Error("--global requires --provider antigravity");
|
|
693
|
+
}
|
|
694
|
+
if (opts.provider) {
|
|
695
|
+
await runProviderScaffold(String(opts.provider), {
|
|
696
|
+
packageRoot: specdojoPackageRootDir(),
|
|
697
|
+
repoRoot: specdojoRootDir(),
|
|
698
|
+
force: !!opts.force,
|
|
699
|
+
dryRun: !!opts.dryRun,
|
|
700
|
+
global: !!opts.global,
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
if (opts.workspace) {
|
|
704
|
+
await runWorkspaceScaffold({
|
|
705
|
+
repoRoot: specdojoRootDir(),
|
|
706
|
+
projectId: opts.project ? String(opts.project) : undefined,
|
|
707
|
+
force: !!opts.force,
|
|
708
|
+
dryRun: !!opts.dryRun,
|
|
709
|
+
});
|
|
710
|
+
}
|
|
576
711
|
}
|
|
577
712
|
catch (error) {
|
|
578
713
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -600,8 +735,12 @@ export function migrateAgentMembers(options) {
|
|
|
600
735
|
if (existsSync(agentPath)) {
|
|
601
736
|
existingAgents = readYamlFile(agentPath);
|
|
602
737
|
validateMemberFile("agent-members.schema.yaml", agentPath, existingAgents);
|
|
738
|
+
validateAgentAliases(agentPath, existingAgents);
|
|
603
739
|
}
|
|
604
|
-
const agentNicknames = new Set(
|
|
740
|
+
const agentNicknames = new Set([
|
|
741
|
+
...existingAgents.members.map((member) => member.nickname),
|
|
742
|
+
...(existingAgents.aliases ?? []).map((alias) => alias.nickname),
|
|
743
|
+
]);
|
|
605
744
|
const moved = [];
|
|
606
745
|
const updates = [];
|
|
607
746
|
for (const [projectId, project] of projectEntries) {
|
|
@@ -628,7 +767,7 @@ export function migrateAgentMembers(options) {
|
|
|
628
767
|
}
|
|
629
768
|
for (const agent of agents) {
|
|
630
769
|
if (agentNicknames.has(agent.nickname)) {
|
|
631
|
-
throw new Error(`Duplicate agent nickname '${agent.nickname}' while migrating ${path}`);
|
|
770
|
+
throw new Error(`Duplicate agent member or alias nickname '${agent.nickname}' while migrating ${path}`);
|
|
632
771
|
}
|
|
633
772
|
agentNicknames.add(agent.nickname);
|
|
634
773
|
moved.push(agent);
|
|
@@ -638,10 +777,12 @@ export function migrateAgentMembers(options) {
|
|
|
638
777
|
updates.push({ path, roster: humanRoster, count: agents.length });
|
|
639
778
|
}
|
|
640
779
|
const mergedAgents = {
|
|
780
|
+
...existingAgents,
|
|
641
781
|
version: existingAgents.version || 1,
|
|
642
782
|
members: [...existingAgents.members, ...moved],
|
|
643
783
|
};
|
|
644
784
|
validateMemberFile("agent-members.schema.yaml", agentPath, mergedAgents);
|
|
785
|
+
validateAgentAliases(agentPath, mergedAgents);
|
|
645
786
|
for (const update of updates) {
|
|
646
787
|
for (const human of update.roster.members) {
|
|
647
788
|
if (agentNicknames.has(human.nickname)) {
|
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { basename, join, relative } from "node:path";
|
|
4
|
-
import { load } from "./yaml.js";
|
|
5
|
-
import { specdojoRootDir } from "./specdojo-config.js";
|
|
6
|
-
export function nowUtcIsoSeconds() {
|
|
7
|
-
return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
8
|
-
}
|
|
9
|
-
export function isUtcIsoSeconds(ts) {
|
|
10
|
-
return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(ts);
|
|
11
|
-
}
|
|
12
|
-
export function tsForFilenameUtc(ts) {
|
|
13
|
-
return ts.replace(/[-:]/g, "").replace("T", "T");
|
|
14
|
-
}
|
|
15
|
-
// worktree/branch 生成専用。project 修飾した task ID(`<projectId>:<taskId>`)を返す。
|
|
16
|
-
// projectId が未解決(env path override 等)の場合は bare のままにして後方互換を保つ。
|
|
17
|
-
// schedule 検索・plan/result ファイル名・claim には使わない(bare の task ID を使う)。
|
|
18
|
-
export function qualifyTaskId(projectId, taskId) {
|
|
19
|
-
return projectId ? `${projectId}:${taskId}` : taskId;
|
|
20
|
-
}
|
|
21
|
-
export function safeSlug(s) {
|
|
22
|
-
return s
|
|
23
|
-
.trim()
|
|
24
|
-
.replace(/\s+/g, "-")
|
|
25
|
-
.replace(/[^A-Za-z0-9._-]/g, "_")
|
|
26
|
-
.slice(0, 80);
|
|
27
|
-
}
|
|
28
|
-
export function randomHex(bytes) {
|
|
29
|
-
return randomBytes(bytes).toString("hex");
|
|
30
|
-
}
|
|
31
|
-
export function ensureDir(path) {
|
|
32
|
-
if (!existsSync(path))
|
|
33
|
-
mkdirSync(path, { recursive: true });
|
|
34
|
-
}
|
|
35
|
-
export function requireNonEmpty(name, v) {
|
|
36
|
-
if (typeof v !== "string" || v.trim().length === 0)
|
|
37
|
-
throw new Error(`${name} is required`);
|
|
38
|
-
return v.trim();
|
|
39
|
-
}
|
|
40
|
-
export function collectRepeatable(value, previous) {
|
|
41
|
-
return previous.concat([value]);
|
|
42
|
-
}
|
|
43
|
-
// CPM 由来の日数値(ES / EF / slack / duration 等)の表示用フォーマット。
|
|
44
|
-
// 浮動小数点誤差(例: 6.2509999999999994)を吸収し、小数点以下を最大2桁に丸める。
|
|
45
|
-
// JSON 等のデータ出力には使わず、Markdown 表示にのみ使う。
|
|
46
|
-
export function formatDays(value) {
|
|
47
|
-
return String(Math.round(value * 100) / 100);
|
|
48
|
-
}
|
|
49
1
|
// East Asian Wide / Fullwidth code point ranges. Characters in these ranges occupy two terminal
|
|
50
2
|
// columns, so they must count as 2 when aligning columns (e.g. Japanese task names in `exec status`).
|
|
51
3
|
const WIDE_CODE_POINT_RANGES = [
|
|
@@ -93,7 +45,10 @@ export function expandTemplate(template, values) {
|
|
|
93
45
|
// `: _PLACEHOLDER_` の空白が行末に残る。生成 plan は prettier の整形対象外
|
|
94
46
|
// (.prettierignore)で checkpoint commit 時に markdownlint の MD009 が直接効くため、
|
|
95
47
|
// ここで行末の空白を取り除く。
|
|
96
|
-
|
|
48
|
+
// 置換値が空のとき(夜間の承認の印がない register 個票の _AUTOPILOT_CONSTRAINTS_、
|
|
49
|
+
// agent の Job の _JOB_EXECUTION_、保守系の _PROJECT_CONTEXT_ など)、前後の空行が重なって
|
|
50
|
+
// MD012 で checkpoint commit が止まるため、2 行以上続く空行を 1 行にまとめる(PJR-283N)。
|
|
51
|
+
return result.replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, "\n\n");
|
|
97
52
|
}
|
|
98
53
|
// 登録簿の自由記述(title / description 列など)を Markdown 本文へ埋め込む際の安全化。
|
|
99
54
|
// `register_date_timezone` のようなアンダースコア入り識別子や `_TODO_` / `_ASSUMPTION_` が、
|
|
@@ -159,89 +114,3 @@ export function redactSensitiveText(value) {
|
|
|
159
114
|
.replace(/\b(sk-(?:proj-)?[A-Za-z0-9_-]{8,}|gh[opsu]_[A-Za-z0-9_]{8,})\b/gu, "[REDACTED]")
|
|
160
115
|
.replace(/\b(api[_-]?key|access[_-]?token|auth(?:orization)?|password|passwd|secret)\b(\s*[:=]\s*)([^\s,;]+)/giu, "$1$2[REDACTED]");
|
|
161
116
|
}
|
|
162
|
-
export function parseKeyValuePairs(pairs) {
|
|
163
|
-
if (!pairs || pairs.length === 0)
|
|
164
|
-
return undefined;
|
|
165
|
-
const out = {};
|
|
166
|
-
for (const p of pairs) {
|
|
167
|
-
const idx = p.indexOf("=");
|
|
168
|
-
if (idx <= 0)
|
|
169
|
-
throw new Error(`Invalid key=value: ${p}`);
|
|
170
|
-
const k = p.slice(0, idx).trim();
|
|
171
|
-
const v = p.slice(idx + 1).trim();
|
|
172
|
-
if (!k)
|
|
173
|
-
throw new Error(`Empty key in: ${p}`);
|
|
174
|
-
out[k] = v;
|
|
175
|
-
}
|
|
176
|
-
return Object.keys(out).length ? out : undefined;
|
|
177
|
-
}
|
|
178
|
-
export function listFilesRecursive(dir) {
|
|
179
|
-
const out = [];
|
|
180
|
-
if (!existsSync(dir))
|
|
181
|
-
return out;
|
|
182
|
-
for (const name of readdirSync(dir)) {
|
|
183
|
-
const full = join(dir, name);
|
|
184
|
-
const st = statSync(full);
|
|
185
|
-
if (st.isDirectory())
|
|
186
|
-
out.push(...listFilesRecursive(full));
|
|
187
|
-
else if (st.isFile())
|
|
188
|
-
out.push(full);
|
|
189
|
-
}
|
|
190
|
-
return out;
|
|
191
|
-
}
|
|
192
|
-
export function readJson(path) {
|
|
193
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
194
|
-
}
|
|
195
|
-
export function isRecord(value) {
|
|
196
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
197
|
-
}
|
|
198
|
-
export function isStringArray(value) {
|
|
199
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
200
|
-
}
|
|
201
|
-
export function writeJson(path, data) {
|
|
202
|
-
writeFileSync(path, JSON.stringify(data, null, 2) + "\n", "utf8");
|
|
203
|
-
}
|
|
204
|
-
export function readYaml(path) {
|
|
205
|
-
return load(readFileSync(path, "utf8"));
|
|
206
|
-
}
|
|
207
|
-
export function isSchYamlFilename(path) {
|
|
208
|
-
const name = basename(path);
|
|
209
|
-
return /^sch-.*\.(yaml|yml)$/.test(name);
|
|
210
|
-
}
|
|
211
|
-
export function sleepMs(ms) {
|
|
212
|
-
const sab = new SharedArrayBuffer(4);
|
|
213
|
-
const int32 = new Int32Array(sab);
|
|
214
|
-
Atomics.wait(int32, 0, 0, ms);
|
|
215
|
-
}
|
|
216
|
-
export function toPortablePath(path) {
|
|
217
|
-
return path.replace(/\\/g, "/");
|
|
218
|
-
}
|
|
219
|
-
export function toArtifactPath(path) {
|
|
220
|
-
const rel = relative(specdojoRootDir(), path);
|
|
221
|
-
return toPortablePath(rel || ".");
|
|
222
|
-
}
|
|
223
|
-
export function toScheduleFilePath(schedulePath, filePath) {
|
|
224
|
-
return toPortablePath(relative(schedulePath, filePath) || ".");
|
|
225
|
-
}
|
|
226
|
-
export function formatDateOnlyUtc(dt) {
|
|
227
|
-
const yyyy = dt.getUTCFullYear().toString().padStart(4, "0");
|
|
228
|
-
const mm = (dt.getUTCMonth() + 1).toString().padStart(2, "0");
|
|
229
|
-
const dd = dt.getUTCDate().toString().padStart(2, "0");
|
|
230
|
-
return `${yyyy}-${mm}-${dd}`;
|
|
231
|
-
}
|
|
232
|
-
export function normalizeDateOnly(value) {
|
|
233
|
-
if (value instanceof Date && !Number.isNaN(value.getTime()))
|
|
234
|
-
return formatDateOnlyUtc(value);
|
|
235
|
-
if (typeof value !== "string")
|
|
236
|
-
return null;
|
|
237
|
-
const trimmed = value.trim();
|
|
238
|
-
if (!trimmed)
|
|
239
|
-
return null;
|
|
240
|
-
const m = trimmed.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
241
|
-
if (m)
|
|
242
|
-
return m[1];
|
|
243
|
-
const dt = new Date(trimmed);
|
|
244
|
-
if (Number.isNaN(dt.getTime()))
|
|
245
|
-
return null;
|
|
246
|
-
return formatDateOnlyUtc(dt);
|
|
247
|
-
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function nowUtcIsoSeconds() {
|
|
2
|
+
return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
3
|
+
}
|
|
4
|
+
export function isUtcIsoSeconds(ts) {
|
|
5
|
+
return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(ts);
|
|
6
|
+
}
|
|
7
|
+
export function formatDateOnlyUtc(dt) {
|
|
8
|
+
const yyyy = dt.getUTCFullYear().toString().padStart(4, "0");
|
|
9
|
+
const mm = (dt.getUTCMonth() + 1).toString().padStart(2, "0");
|
|
10
|
+
const dd = dt.getUTCDate().toString().padStart(2, "0");
|
|
11
|
+
return `${yyyy}-${mm}-${dd}`;
|
|
12
|
+
}
|
|
13
|
+
export function normalizeDateOnly(value) {
|
|
14
|
+
if (value instanceof Date && !Number.isNaN(value.getTime()))
|
|
15
|
+
return formatDateOnlyUtc(value);
|
|
16
|
+
if (typeof value !== "string")
|
|
17
|
+
return null;
|
|
18
|
+
const trimmed = value.trim();
|
|
19
|
+
if (!trimmed)
|
|
20
|
+
return null;
|
|
21
|
+
const m = trimmed.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
22
|
+
if (m)
|
|
23
|
+
return m[1];
|
|
24
|
+
const dt = new Date(trimmed);
|
|
25
|
+
if (Number.isNaN(dt.getTime()))
|
|
26
|
+
return null;
|
|
27
|
+
return formatDateOnlyUtc(dt);
|
|
28
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, join, resolve } from "node:path";
|
|
3
|
+
import { specdojoRootDir } from "./specdojo-config.js";
|
|
4
|
+
export function buildWorkspaceData(repoName, repos) {
|
|
5
|
+
return {
|
|
6
|
+
folders: [
|
|
7
|
+
{ name: repoName, path: "." },
|
|
8
|
+
...repos.map((repo) => ({ name: repo.name, path: repo.path })),
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function renderWorkspaceContent(repoName, repos) {
|
|
13
|
+
const data = buildWorkspaceData(repoName, repos);
|
|
14
|
+
return `${JSON.stringify(data, null, 2)}\n`;
|
|
15
|
+
}
|
|
16
|
+
export async function runWorkspaceScaffold(options = {}) {
|
|
17
|
+
const repoRoot = options.repoRoot ? resolve(options.repoRoot) : specdojoRootDir();
|
|
18
|
+
const configPath = join(repoRoot, ".specdojo", "specdojo.config.json");
|
|
19
|
+
if (!existsSync(configPath)) {
|
|
20
|
+
throw new Error(`No config found: ${configPath}`);
|
|
21
|
+
}
|
|
22
|
+
let config;
|
|
23
|
+
try {
|
|
24
|
+
config = JSON.parse(readFileSync(configPath, "utf8"));
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw new Error(`Failed to parse config: ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
28
|
+
}
|
|
29
|
+
const projectId = options.projectId || config.current_project;
|
|
30
|
+
if (!projectId) {
|
|
31
|
+
throw new Error("No current_project configured. Specify --project <id>.");
|
|
32
|
+
}
|
|
33
|
+
const project = config.projects?.[projectId];
|
|
34
|
+
if (!project) {
|
|
35
|
+
throw new Error(`Unknown project: ${projectId}`);
|
|
36
|
+
}
|
|
37
|
+
if (!project.repos || project.repos.length === 0) {
|
|
38
|
+
throw new Error(`Project '${projectId}' has no 'repos' configured in ${configPath}. Declare 'repos' in the project configuration before scaffolding a multi-root workspace.`);
|
|
39
|
+
}
|
|
40
|
+
const repoName = basename(repoRoot);
|
|
41
|
+
const fileName = `${projectId}.code-workspace`;
|
|
42
|
+
const filePath = join(repoRoot, fileName);
|
|
43
|
+
if (existsSync(filePath) && !options.force) {
|
|
44
|
+
if (options.dryRun) {
|
|
45
|
+
process.stdout.write(`[dry-run] skipped: ${fileName} already exists (use --force to overwrite)\n`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
process.stdout.write(`Skipped (already exists): ${fileName}\n`);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
status: "skipped",
|
|
52
|
+
relativePath: fileName,
|
|
53
|
+
absolutePath: filePath,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const content = renderWorkspaceContent(repoName, project.repos);
|
|
57
|
+
if (options.dryRun) {
|
|
58
|
+
process.stdout.write(`[dry-run] would write: ${fileName}\n`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
writeFileSync(filePath, content, "utf8");
|
|
62
|
+
process.stdout.write(`Written: ${fileName}\n`);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
status: "written",
|
|
66
|
+
relativePath: fileName,
|
|
67
|
+
absolutePath: filePath,
|
|
68
|
+
};
|
|
69
|
+
}
|
package/dist/specdojo.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import { evaluateDistFreshness, inspectDistEntryFreshness } from "./dist-freshness.js";
|
|
5
|
-
import { specdojoPackageVersion } from "./package-paths.js";
|
|
6
|
-
import { registerConfigCommands, registerProjectCommands } from "./specdojo-config.js";
|
|
7
|
-
import { registerExecCommands } from "./exec.js";
|
|
8
|
-
import { registerCatalogCommands } from "./catalog.js";
|
|
9
|
-
import { registerDeliverableCommands } from "./deliverable.js";
|
|
10
|
-
import { registerScheduleCommands } from "./schedule.js";
|
|
11
|
-
import { registerTimelineCommands } from "./timeline.js";
|
|
12
|
-
import { registerIndexCommands } from "./index-command.js";
|
|
13
|
-
import { registerRegisterCommands } from "./register.js";
|
|
14
|
-
import { registerRoutineCommands } from "./routine.js";
|
|
15
|
-
import { registerJobCommands } from "./job.js";
|
|
16
|
-
import { registerWatchCommand } from "./watch.js";
|
|
17
|
-
import { registerBuildCommand } from "./build
|
|
18
|
-
import { registerYamlPagesCommands } from "./yaml-pages-command.js";
|
|
19
|
-
import { registerDashboardCommands } from "./dashboard.js";
|
|
20
|
-
import { registerGradeCommand } from "./grade.js";
|
|
21
|
-
import { registerAgentCommands } from "./agent.js";
|
|
22
|
-
import { registerKataCommands } from "./kata
|
|
23
|
-
import { registerDevcontainerCommands } from "./devcontainer
|
|
24
|
-
import { registerInitCommand } from "./init
|
|
25
|
-
import { registerOrchestratorCommands } from "./orchestrator.js";
|
|
4
|
+
import { evaluateDistFreshness, inspectDistEntryFreshness } from "./shared/dist-freshness.js";
|
|
5
|
+
import { specdojoPackageVersion } from "./shared/package-paths.js";
|
|
6
|
+
import { registerConfigCommands, registerProjectCommands } from "./shared/specdojo-config.js";
|
|
7
|
+
import { registerExecCommands } from "./exec/exec.js";
|
|
8
|
+
import { registerCatalogCommands } from "./catalog/catalog.js";
|
|
9
|
+
import { registerDeliverableCommands } from "./deliverable/deliverable.js";
|
|
10
|
+
import { registerScheduleCommands } from "./schedule/schedule.js";
|
|
11
|
+
import { registerTimelineCommands } from "./dashboard/timeline.js";
|
|
12
|
+
import { registerIndexCommands } from "./docs/index-command.js";
|
|
13
|
+
import { registerRegisterCommands } from "./register/register.js";
|
|
14
|
+
import { registerRoutineCommands } from "./routine/routine.js";
|
|
15
|
+
import { registerJobCommands } from "./job/job.js";
|
|
16
|
+
import { registerWatchCommand } from "./commands/watch.js";
|
|
17
|
+
import { registerBuildCommand } from "./commands/build.js";
|
|
18
|
+
import { registerYamlPagesCommands } from "./docs/yaml-pages-command.js";
|
|
19
|
+
import { registerDashboardCommands } from "./dashboard/dashboard.js";
|
|
20
|
+
import { registerGradeCommand } from "./grade/grade.js";
|
|
21
|
+
import { registerAgentCommands } from "./commands/agent.js";
|
|
22
|
+
import { registerKataCommands } from "./kata/command.js";
|
|
23
|
+
import { registerDevcontainerCommands } from "./devcontainer/command.js";
|
|
24
|
+
import { registerInitCommand } from "./commands/init.js";
|
|
25
|
+
import { registerOrchestratorCommands } from "./commands/orchestrator.js";
|
|
26
26
|
/**
|
|
27
27
|
* bin は dist/specdojo.js を指すため、開発チェックアウトで `npm run build` を忘れると
|
|
28
28
|
* 古い挙動のまま実行される。src が dist より新しい場合は警告し、exec 系は中断する。
|