@opengsd/gsd-core 1.4.2 → 1.5.0-rc.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/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -3
- package/agents/gsd-executor.md +1 -1
- package/agents/gsd-plan-checker.md +11 -2
- package/agents/gsd-planner.md +11 -7
- package/agents/gsd-verifier.md +3 -3
- package/bin/install.js +947 -149
- package/commands/gsd/autonomous.md +5 -1
- package/commands/gsd/ns-manage.md +8 -1
- package/commands/gsd/ns-project.md +5 -0
- package/commands/gsd/ns-review.md +4 -1
- package/commands/gsd/ns-workflow.md +7 -1
- package/commands/gsd/plan-review-convergence.md +6 -5
- package/commands/gsd/surface.md +12 -5
- package/gemini-extension.json +1 -1
- package/gsd-core/bin/gsd-tools.cjs +198 -101
- package/gsd-core/bin/lib/audit-command-router.cjs +61 -0
- package/gsd-core/bin/lib/capability-registry.cjs +417 -0
- package/gsd-core/bin/lib/capability-state.cjs +336 -0
- package/gsd-core/bin/lib/cli-exit.cjs +22 -3
- package/gsd-core/bin/lib/config-loader.cjs +716 -0
- package/gsd-core/bin/lib/configuration.cjs +4 -34
- package/gsd-core/bin/lib/core-utils.cjs +198 -0
- package/gsd-core/bin/lib/core.cjs +57 -1817
- package/gsd-core/bin/lib/federated-config.cjs +182 -0
- package/gsd-core/bin/lib/graphify-command-router.cjs +74 -0
- package/gsd-core/bin/lib/init.cjs +58 -12
- package/gsd-core/bin/lib/install-profiles.cjs +157 -3
- package/gsd-core/bin/lib/installer-migrations/004-prune-stale-pristine-snapshots.cjs +123 -0
- package/gsd-core/bin/lib/intel-command-router.cjs +116 -0
- package/gsd-core/bin/lib/io.cjs +167 -0
- package/gsd-core/bin/lib/loop-host-contract.cjs +105 -0
- package/gsd-core/bin/lib/loop-resolver.cjs +460 -0
- package/gsd-core/bin/lib/model-resolver.cjs +426 -0
- package/gsd-core/bin/lib/phase-id.cjs +215 -0
- package/gsd-core/bin/lib/phase-locator.cjs +148 -0
- package/gsd-core/bin/lib/profile-pipeline.cjs +2 -2
- package/gsd-core/bin/lib/roadmap-parser.cjs +443 -0
- package/gsd-core/bin/lib/roadmap.cjs +4 -1
- package/gsd-core/bin/lib/runtime-artifact-layout.cjs +96 -9
- package/gsd-core/bin/lib/runtime-config-adapter-registry.cjs +2 -1
- package/gsd-core/bin/lib/runtime-homes.cjs +40 -0
- package/gsd-core/bin/lib/runtime-name-policy.cjs +1 -0
- package/gsd-core/bin/lib/shell-command-projection.cjs +13 -0
- package/gsd-core/bin/lib/state.cjs +114 -2
- package/gsd-core/bin/lib/surface.cjs +66 -14
- package/gsd-core/bin/lib/verify.cjs +1 -1
- package/gsd-core/bin/shared/model-catalog.json +5 -0
- package/gsd-core/bin/shared/runtime-aliases.manifest.json +3 -0
- package/gsd-core/bin/verify-reapply-patches.cjs +57 -7
- package/gsd-core/references/planner-reviews.md +5 -2
- package/gsd-core/templates/phase-prompt.md +7 -7
- package/gsd-core/templates/project.md +19 -2
- package/gsd-core/templates/summary-complex.md +1 -0
- package/gsd-core/templates/summary-minimal.md +1 -0
- package/gsd-core/templates/summary-standard.md +1 -0
- package/gsd-core/templates/summary.md +1 -0
- package/gsd-core/workflows/_runtime-launcher.snippet.sh +1 -1
- package/gsd-core/workflows/add-backlog.md +1 -1
- package/gsd-core/workflows/add-phase.md +1 -1
- package/gsd-core/workflows/add-tests.md +1 -1
- package/gsd-core/workflows/add-todo.md +1 -1
- package/gsd-core/workflows/ai-integration-phase.md +1 -1
- package/gsd-core/workflows/audit-fix.md +1 -1
- package/gsd-core/workflows/audit-milestone.md +1 -1
- package/gsd-core/workflows/audit-uat.md +1 -1
- package/gsd-core/workflows/autonomous.md +86 -15
- package/gsd-core/workflows/check-todos.md +1 -1
- package/gsd-core/workflows/cleanup.md +1 -1
- package/gsd-core/workflows/code-review-fix.md +6 -4
- package/gsd-core/workflows/code-review.md +3 -2
- package/gsd-core/workflows/complete-milestone.md +11 -5
- package/gsd-core/workflows/debug.md +1 -1
- package/gsd-core/workflows/diagnose-issues.md +1 -1
- package/gsd-core/workflows/discuss-phase/modes/advisor.md +1 -1
- package/gsd-core/workflows/discuss-phase/modes/auto.md +1 -1
- package/gsd-core/workflows/discuss-phase/modes/chain.md +1 -1
- package/gsd-core/workflows/discuss-phase-assumptions.md +1 -1
- package/gsd-core/workflows/discuss-phase.md +8 -1
- package/gsd-core/workflows/do.md +1 -1
- package/gsd-core/workflows/docs-update.md +1 -1
- package/gsd-core/workflows/edit-phase.md +1 -1
- package/gsd-core/workflows/eval-review.md +4 -1
- package/gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md +1 -1
- package/gsd-core/workflows/execute-phase/steps/post-merge-gate.md +1 -1
- package/gsd-core/workflows/execute-phase.md +8 -1
- package/gsd-core/workflows/execute-plan.md +1 -1
- package/gsd-core/workflows/explore.md +1 -1
- package/gsd-core/workflows/extract-learnings.md +1 -1
- package/gsd-core/workflows/forensics.md +1 -1
- package/gsd-core/workflows/graduation.md +1 -1
- package/gsd-core/workflows/health.md +1 -1
- package/gsd-core/workflows/help/modes/full.md +1 -1
- package/gsd-core/workflows/import.md +1 -1
- package/gsd-core/workflows/ingest-docs.md +1 -1
- package/gsd-core/workflows/insert-phase.md +1 -1
- package/gsd-core/workflows/list-workspaces.md +1 -1
- package/gsd-core/workflows/manager.md +1 -1
- package/gsd-core/workflows/map-codebase.md +1 -1
- package/gsd-core/workflows/milestone-summary.md +1 -1
- package/gsd-core/workflows/mvp-phase.md +1 -1
- package/gsd-core/workflows/new-milestone.md +1 -1
- package/gsd-core/workflows/new-project.md +1 -1
- package/gsd-core/workflows/new-workspace.md +1 -1
- package/gsd-core/workflows/next.md +1 -1
- package/gsd-core/workflows/pause-work.md +1 -1
- package/gsd-core/workflows/plan-milestone-gaps.md +1 -1
- package/gsd-core/workflows/plan-phase.md +27 -2
- package/gsd-core/workflows/plan-review-convergence.md +76 -63
- package/gsd-core/workflows/plant-seed.md +1 -1
- package/gsd-core/workflows/profile-user.md +1 -1
- package/gsd-core/workflows/progress.md +1 -1
- package/gsd-core/workflows/quick.md +2 -2
- package/gsd-core/workflows/reapply-patches.md +18 -1
- package/gsd-core/workflows/remove-phase.md +1 -1
- package/gsd-core/workflows/remove-workspace.md +1 -1
- package/gsd-core/workflows/resume-project.md +1 -1
- package/gsd-core/workflows/review.md +1 -1
- package/gsd-core/workflows/scan.md +1 -1
- package/gsd-core/workflows/secure-phase.md +1 -1
- package/gsd-core/workflows/settings-advanced.md +1 -1
- package/gsd-core/workflows/settings-integrations.md +1 -1
- package/gsd-core/workflows/settings.md +1 -1
- package/gsd-core/workflows/ship.md +8 -1
- package/gsd-core/workflows/sketch-wrap-up.md +1 -1
- package/gsd-core/workflows/sketch.md +1 -1
- package/gsd-core/workflows/spec-phase.md +1 -1
- package/gsd-core/workflows/spike-wrap-up.md +1 -1
- package/gsd-core/workflows/spike.md +1 -1
- package/gsd-core/workflows/stats.md +1 -1
- package/gsd-core/workflows/thread.md +1 -1
- package/gsd-core/workflows/transition.md +1 -1
- package/gsd-core/workflows/ui-phase.md +1 -1
- package/gsd-core/workflows/ui-review.md +1 -1
- package/gsd-core/workflows/ultraplan-phase.md +1 -1
- package/gsd-core/workflows/update.md +20 -15
- package/gsd-core/workflows/validate-phase.md +1 -1
- package/gsd-core/workflows/verify-phase.md +1 -1
- package/gsd-core/workflows/verify-work.md +8 -1
- package/package.json +7 -2
- package/scripts/base64-scan.sh +1 -1
- package/scripts/changeset/cli.cjs +9 -2
- package/scripts/changeset/lint.cjs +38 -2
- package/scripts/ci-test-scope.cjs +21 -10
- package/scripts/gen-capability-registry.cjs +1808 -0
- package/scripts/gen-loop-host-contract.cjs +471 -0
- package/scripts/lint-regression-test-names.allowlist.json +269 -0
- package/scripts/lint-regression-test-names.cjs +117 -0
- package/scripts/lint-test-file-count.allowlist.json +12 -4
- package/scripts/prompt-injection-scan.sh +4 -4
- package/scripts/run-tests.cjs +79 -16
- package/scripts/secret-scan.sh +3 -3
- package/scripts/run-cross-platform-tests.cjs +0 -67
|
@@ -0,0 +1,716 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Config Loader — Project configuration loading
|
|
4
|
+
*
|
|
5
|
+
* ADR-857 rollout phase 2e: extracted from core.cts (issue #885).
|
|
6
|
+
* Owns project configuration loading: reads `.planning/config.json`,
|
|
7
|
+
* merges built-in defaults (`CONFIG_DEFAULTS`/`CANONICAL_CONFIG_DEFAULTS`),
|
|
8
|
+
* normalizes legacy keys, applies the active-workstream overlay, validates
|
|
9
|
+
* against the config schema, and warns on unknown keys/profile overrides.
|
|
10
|
+
* Behaviour is preserved byte-for-behaviour from the prior location; only
|
|
11
|
+
* the module boundary moved. core.cjs re-exports `loadConfig` for back-compat.
|
|
12
|
+
*
|
|
13
|
+
* New imports should pull loadConfig from config-loader.cjs directly.
|
|
14
|
+
*
|
|
15
|
+
* Dependencies (leaf modules only — no core.cjs):
|
|
16
|
+
* - node:fs / node:os / node:path (stdlib)
|
|
17
|
+
* - ./configuration.cjs (normalizeLegacyKeys, CONFIG_DEFAULTS as CANONICAL_CONFIG_DEFAULTS)
|
|
18
|
+
* - ./config-schema.cjs (VALID_CONFIG_KEYS, DYNAMIC_KEY_PATTERNS)
|
|
19
|
+
* - ./planning-workspace.cjs (planningDir, planningRoot)
|
|
20
|
+
* - ./shell-command-projection.cjs (execGit, platformWriteSync, platformReadSync)
|
|
21
|
+
* - ./core-utils.cjs (detectSubRepos)
|
|
22
|
+
* - ./model-catalog.cjs (KNOWN_RUNTIMES, KNOWN_PROVIDERS)
|
|
23
|
+
*/
|
|
24
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
+
};
|
|
27
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
28
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
29
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
30
|
+
const shell_command_projection_cjs_1 = require("./shell-command-projection.cjs");
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
32
|
+
const planningWorkspace = require("./planning-workspace.cjs");
|
|
33
|
+
const { planningDir, planningRoot } = planningWorkspace;
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
35
|
+
const coreUtilsModule = require("./core-utils.cjs");
|
|
36
|
+
const { detectSubRepos } = coreUtilsModule;
|
|
37
|
+
// ─── Configuration Module (generated CJS mirror) ────────────────────────────
|
|
38
|
+
const configuration_cjs_1 = require("./configuration.cjs");
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
40
|
+
const configSchema = require("./config-schema.cjs");
|
|
41
|
+
const { VALID_CONFIG_KEYS, DYNAMIC_KEY_PATTERNS, isValidConfigKey: _isValidConfigKeyFn } = configSchema;
|
|
42
|
+
const model_catalog_cjs_1 = require("./model-catalog.cjs");
|
|
43
|
+
// ─── Federated Config (ADR-857 phase 3b) ─────────────────────────────────────
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
45
|
+
const federatedConfigModule = require("./federated-config.cjs");
|
|
46
|
+
const { mergeFederatedConfig } = federatedConfigModule;
|
|
47
|
+
// The capability-registry.cjs is generated and lives in the same gsd-core/bin/lib/ output dir.
|
|
48
|
+
// Both config-loader.cjs and capability-registry.cjs land in gsd-core/bin/lib/ at build time.
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment
|
|
50
|
+
const _capabilityRegistryReal = require('./capability-registry.cjs');
|
|
51
|
+
// Module-level registry reference. Defaults to the real generated registry.
|
|
52
|
+
// Overridable for tests via _setFederatedRegistryForTests.
|
|
53
|
+
let _capabilityRegistry = _capabilityRegistryReal;
|
|
54
|
+
/** Test-only seam: inject a synthetic registry. Call _resetFederatedRegistryForTests() to restore. */
|
|
55
|
+
function _setFederatedRegistryForTests(reg) {
|
|
56
|
+
_capabilityRegistry = reg;
|
|
57
|
+
}
|
|
58
|
+
/** Test-only seam: restore the real generated registry. */
|
|
59
|
+
function _resetFederatedRegistryForTests() {
|
|
60
|
+
_capabilityRegistry = _capabilityRegistryReal;
|
|
61
|
+
}
|
|
62
|
+
// ─── File & Config utilities ──────────────────────────────────────────────────
|
|
63
|
+
/**
|
|
64
|
+
* Canonical config defaults — flat-key projection for CJS consumers.
|
|
65
|
+
*
|
|
66
|
+
* Cycle 4: Values are sourced from CANONICAL_CONFIG_DEFAULTS (the nested
|
|
67
|
+
* manifest loaded by configuration.generated.cjs). The flat shape is
|
|
68
|
+
* preserved here so legacy consumers (config.cjs, verify.cjs, tests that
|
|
69
|
+
* regex-parse this source) continue to work without changes. The key names
|
|
70
|
+
* and the `const CONFIG_DEFAULTS = {` pattern are intentionally kept.
|
|
71
|
+
*
|
|
72
|
+
* Mapping notes:
|
|
73
|
+
* - workflow.plan_check → plan_checker (CJS flat name; verify.cjs uses this)
|
|
74
|
+
* - git.* → flat git keys (branching_strategy, templates)
|
|
75
|
+
* - workflow.* → flat names (research, verifier, …)
|
|
76
|
+
* - planning.sub_repos → sub_repos
|
|
77
|
+
* - planning.commit_docs / search_gitignored → top-level flat keys
|
|
78
|
+
*/
|
|
79
|
+
// CANONICAL_CONFIG_DEFAULTS is typed as Record<string, unknown> from configuration.cjs;
|
|
80
|
+
// we use a typed accessor to avoid repeated casts.
|
|
81
|
+
function _getConfigDefault(key) {
|
|
82
|
+
return (configuration_cjs_1.CONFIG_DEFAULTS)[key];
|
|
83
|
+
}
|
|
84
|
+
function _getNestedConfigDefault(section, field) {
|
|
85
|
+
const sec = (configuration_cjs_1.CONFIG_DEFAULTS)[section];
|
|
86
|
+
if (sec && typeof sec === 'object' && !Array.isArray(sec)) {
|
|
87
|
+
return sec[field];
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
const CONFIG_DEFAULTS = {
|
|
92
|
+
model_profile: _getConfigDefault('model_profile'),
|
|
93
|
+
commit_docs: _getConfigDefault('commit_docs'),
|
|
94
|
+
search_gitignored: _getConfigDefault('search_gitignored'),
|
|
95
|
+
branching_strategy: _getNestedConfigDefault('git', 'branching_strategy'),
|
|
96
|
+
phase_branch_template: _getNestedConfigDefault('git', 'phase_branch_template'),
|
|
97
|
+
milestone_branch_template: _getNestedConfigDefault('git', 'milestone_branch_template'),
|
|
98
|
+
quick_branch_template: _getNestedConfigDefault('git', 'quick_branch_template'),
|
|
99
|
+
research: _getNestedConfigDefault('workflow', 'research'),
|
|
100
|
+
plan_checker: _getNestedConfigDefault('workflow', 'plan_check'), // flat CJS name maps to workflow.plan_check
|
|
101
|
+
verifier: _getNestedConfigDefault('workflow', 'verifier'),
|
|
102
|
+
nyquist_validation: _getNestedConfigDefault('workflow', 'nyquist_validation'),
|
|
103
|
+
ai_integration_phase: _getNestedConfigDefault('workflow', 'ai_integration_phase'),
|
|
104
|
+
parallelization: _getConfigDefault('parallelization'),
|
|
105
|
+
brave_search: _getConfigDefault('brave_search'),
|
|
106
|
+
firecrawl: _getConfigDefault('firecrawl'),
|
|
107
|
+
exa_search: _getConfigDefault('exa_search'),
|
|
108
|
+
text_mode: _getNestedConfigDefault('workflow', 'text_mode'),
|
|
109
|
+
sub_repos: _getNestedConfigDefault('planning', 'sub_repos'),
|
|
110
|
+
resolve_model_ids: _getConfigDefault('resolve_model_ids'),
|
|
111
|
+
context_window: _getConfigDefault('context_window'),
|
|
112
|
+
phase_naming: _getConfigDefault('phase_naming'),
|
|
113
|
+
project_code: _getConfigDefault('project_code'),
|
|
114
|
+
subagent_timeout: _getNestedConfigDefault('workflow', 'subagent_timeout'),
|
|
115
|
+
security_enforcement: _getNestedConfigDefault('workflow', 'security_enforcement'),
|
|
116
|
+
security_asvs_level: _getNestedConfigDefault('workflow', 'security_asvs_level'),
|
|
117
|
+
security_block_on: _getNestedConfigDefault('workflow', 'security_block_on'),
|
|
118
|
+
post_planning_gaps: _getNestedConfigDefault('workflow', 'post_planning_gaps'),
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Deep-merge two plain config objects. `overlay` wins on key conflict.
|
|
122
|
+
* Explicit `null` in overlay overrides base (null means "unset this key").
|
|
123
|
+
* Arrays are replaced, not merged. Non-object primitives use overlay value.
|
|
124
|
+
*
|
|
125
|
+
* Note: `undefined` in overlay is treated as "no value provided" and falls
|
|
126
|
+
* back to base (preserves inheritance). Explicit `null` overrides base.
|
|
127
|
+
*/
|
|
128
|
+
function _deepMergeConfig(base, overlay) {
|
|
129
|
+
if (overlay === null || overlay === undefined)
|
|
130
|
+
return overlay;
|
|
131
|
+
if (typeof base !== 'object' || typeof overlay !== 'object')
|
|
132
|
+
return overlay;
|
|
133
|
+
const result = { ...base };
|
|
134
|
+
for (const key of Object.keys(overlay)) {
|
|
135
|
+
if (overlay[key] !== null && typeof overlay[key] === 'object' && !Array.isArray(overlay[key])) {
|
|
136
|
+
result[key] = _deepMergeConfig((base[key] ?? {}), overlay[key]);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
result[key] = overlay[key];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
// Module-level deduplication for unknown-key warnings (#3523).
|
|
145
|
+
// A single `init phase-op N` call invokes loadConfig more than once; this Set
|
|
146
|
+
// prevents the same warning from being echoed on each invocation.
|
|
147
|
+
const _warnedUnknownConfigKeys = new Set();
|
|
148
|
+
// ─── Git utilities ────────────────────────────────────────────────────────────
|
|
149
|
+
const _gitIgnoredCache = new Map();
|
|
150
|
+
function isGitIgnored(cwd, targetPath) {
|
|
151
|
+
const key = cwd + '::' + targetPath;
|
|
152
|
+
if (_gitIgnoredCache.has(key))
|
|
153
|
+
return _gitIgnoredCache.get(key);
|
|
154
|
+
// --no-index checks .gitignore rules regardless of whether the file is tracked.
|
|
155
|
+
const result = (0, shell_command_projection_cjs_1.execGit)(['check-ignore', '-q', '--no-index', '--', targetPath], { cwd });
|
|
156
|
+
const ignored = result.exitCode === 0;
|
|
157
|
+
_gitIgnoredCache.set(key, ignored);
|
|
158
|
+
return ignored;
|
|
159
|
+
}
|
|
160
|
+
// ─── Model alias resolution ───────────────────────────────────────────────────
|
|
161
|
+
const RUNTIME_OVERRIDE_TIERS = new Set(['opus', 'sonnet', 'haiku']);
|
|
162
|
+
const _warnedConfigKeys = new Set();
|
|
163
|
+
function _warnUnknownProfileOverrides(parsed, configLabel) {
|
|
164
|
+
if (!parsed || typeof parsed !== 'object')
|
|
165
|
+
return;
|
|
166
|
+
const runtime = parsed['runtime'];
|
|
167
|
+
if (runtime && typeof runtime === 'string' && !(model_catalog_cjs_1.KNOWN_RUNTIMES).has(runtime)) {
|
|
168
|
+
const key = `${configLabel}::runtime::${runtime}`;
|
|
169
|
+
if (!_warnedConfigKeys.has(key)) {
|
|
170
|
+
_warnedConfigKeys.add(key);
|
|
171
|
+
try {
|
|
172
|
+
process.stderr.write(`gsd: warning — config key "runtime" has unknown value "${runtime}". ` +
|
|
173
|
+
`Known runtimes: ${[...(model_catalog_cjs_1.KNOWN_RUNTIMES)].sort().join(', ')}. ` +
|
|
174
|
+
`Resolution will fall back to safe defaults. (#2517)\n`);
|
|
175
|
+
}
|
|
176
|
+
catch { /* stderr might be closed in some test harnesses */ }
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const overrides = parsed['model_profile_overrides'];
|
|
180
|
+
if (overrides && typeof overrides === 'object' && !Array.isArray(overrides)) {
|
|
181
|
+
for (const [overrideRuntime, tierMap] of Object.entries(overrides)) {
|
|
182
|
+
if (!(model_catalog_cjs_1.KNOWN_RUNTIMES).has(overrideRuntime)) {
|
|
183
|
+
const key = `${configLabel}::override-runtime::${overrideRuntime}`;
|
|
184
|
+
if (!_warnedConfigKeys.has(key)) {
|
|
185
|
+
_warnedConfigKeys.add(key);
|
|
186
|
+
try {
|
|
187
|
+
process.stderr.write(`gsd: warning — model_profile_overrides.${overrideRuntime}.* uses ` +
|
|
188
|
+
`unknown runtime "${overrideRuntime}". Known runtimes: ` +
|
|
189
|
+
`${[...(model_catalog_cjs_1.KNOWN_RUNTIMES)].sort().join(', ')}. (#2517)\n`);
|
|
190
|
+
}
|
|
191
|
+
catch { /* ok */ }
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!tierMap || typeof tierMap !== 'object')
|
|
195
|
+
continue;
|
|
196
|
+
for (const tierName of Object.keys(tierMap)) {
|
|
197
|
+
if (!RUNTIME_OVERRIDE_TIERS.has(tierName)) {
|
|
198
|
+
const key = `${configLabel}::override-tier::${overrideRuntime}.${tierName}`;
|
|
199
|
+
if (!_warnedConfigKeys.has(key)) {
|
|
200
|
+
_warnedConfigKeys.add(key);
|
|
201
|
+
try {
|
|
202
|
+
process.stderr.write(`gsd: warning — model_profile_overrides.${overrideRuntime}.${tierName} ` +
|
|
203
|
+
`uses unknown tier "${tierName}". Allowed tiers: opus, sonnet, haiku. (#2517)\n`);
|
|
204
|
+
}
|
|
205
|
+
catch { /* ok */ }
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const policy = parsed['model_policy'];
|
|
212
|
+
if (policy && typeof policy === 'object' && !Array.isArray(policy)) {
|
|
213
|
+
const policyObj = policy;
|
|
214
|
+
const provider = policyObj['provider'];
|
|
215
|
+
const _POLICY_SENTINEL_PROVIDERS = new Set(['generic', 'custom']);
|
|
216
|
+
if (provider && typeof provider === 'string' &&
|
|
217
|
+
!(model_catalog_cjs_1.KNOWN_PROVIDERS).has(provider) && !_POLICY_SENTINEL_PROVIDERS.has(provider)) {
|
|
218
|
+
const pkey = `${configLabel}::model_policy::provider::${provider}`;
|
|
219
|
+
if (!_warnedConfigKeys.has(pkey)) {
|
|
220
|
+
_warnedConfigKeys.add(pkey);
|
|
221
|
+
try {
|
|
222
|
+
process.stderr.write(`gsd: warning — model_policy.provider has unknown value "${provider}". ` +
|
|
223
|
+
`Known providers: ${[...(model_catalog_cjs_1.KNOWN_PROVIDERS)].sort().join(', ')}. ` +
|
|
224
|
+
`For manual model IDs use provider="custom". (#49)\n`);
|
|
225
|
+
}
|
|
226
|
+
catch { /* ok */ }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const rtOverrides = policyObj['runtime_tiers'];
|
|
230
|
+
if (rtOverrides && typeof rtOverrides === 'object' && !Array.isArray(rtOverrides)) {
|
|
231
|
+
for (const [pruntime, tierMap] of Object.entries(rtOverrides)) {
|
|
232
|
+
if (!(model_catalog_cjs_1.KNOWN_RUNTIMES).has(pruntime)) {
|
|
233
|
+
const key = `${configLabel}::model_policy.runtime_tiers::${pruntime}`;
|
|
234
|
+
if (!_warnedConfigKeys.has(key)) {
|
|
235
|
+
_warnedConfigKeys.add(key);
|
|
236
|
+
try {
|
|
237
|
+
process.stderr.write(`gsd: warning — model_policy.runtime_tiers.${pruntime}.* uses ` +
|
|
238
|
+
`unknown runtime "${pruntime}". Known runtimes: ` +
|
|
239
|
+
`${[...(model_catalog_cjs_1.KNOWN_RUNTIMES)].sort().join(', ')}. (#49)\n`);
|
|
240
|
+
}
|
|
241
|
+
catch { /* ok */ }
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!tierMap || typeof tierMap !== 'object')
|
|
245
|
+
continue;
|
|
246
|
+
for (const tierName of Object.keys(tierMap)) {
|
|
247
|
+
if (!RUNTIME_OVERRIDE_TIERS.has(tierName)) {
|
|
248
|
+
const key = `${configLabel}::model_policy.runtime_tiers::${pruntime}.${tierName}`;
|
|
249
|
+
if (!_warnedConfigKeys.has(key)) {
|
|
250
|
+
_warnedConfigKeys.add(key);
|
|
251
|
+
try {
|
|
252
|
+
process.stderr.write(`gsd: warning — model_policy.runtime_tiers.${pruntime}.${tierName} ` +
|
|
253
|
+
`uses unknown tier "${tierName}". Allowed: opus, sonnet, haiku. (#49)\n`);
|
|
254
|
+
}
|
|
255
|
+
catch { /* ok */ }
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// Internal helper exposed for tests so per-process warning state can be reset
|
|
264
|
+
// between cases that intentionally exercise the warning path repeatedly.
|
|
265
|
+
function _resetRuntimeWarningCacheForTests() {
|
|
266
|
+
_warnedConfigKeys.clear();
|
|
267
|
+
}
|
|
268
|
+
// ─── FIX 2: Federated overlay helpers ────────────────────────────────────────
|
|
269
|
+
/**
|
|
270
|
+
* Apply federated key values into a mutable config object.
|
|
271
|
+
* Handles N-level dotted keys (e.g. "a.b.c" → obj.a.b.c).
|
|
272
|
+
* Only adds keys that are not already present (does not clobber).
|
|
273
|
+
* Inline prototype-pollution guards at every segment.
|
|
274
|
+
*/
|
|
275
|
+
function _applyFederatedValues(obj, values, validKeys) {
|
|
276
|
+
for (const dottedKey of validKeys) {
|
|
277
|
+
// S2: inline literal guard on full key
|
|
278
|
+
if (dottedKey === '__proto__' || dottedKey === 'constructor' || dottedKey === 'prototype')
|
|
279
|
+
continue;
|
|
280
|
+
const parts = dottedKey.split('.');
|
|
281
|
+
if (parts.length === 1) {
|
|
282
|
+
const topKey = parts[0];
|
|
283
|
+
if (topKey !== '__proto__' && topKey !== 'constructor' && topKey !== 'prototype') {
|
|
284
|
+
if (!Object.prototype.hasOwnProperty.call(obj, topKey)) {
|
|
285
|
+
obj[topKey] = values[dottedKey];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
// N-level nested key: traverse/create intermediate objects
|
|
291
|
+
let cur = obj;
|
|
292
|
+
let ok = true;
|
|
293
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
294
|
+
const seg = parts[i];
|
|
295
|
+
// S2: inline literal guard on each segment
|
|
296
|
+
if (seg === '__proto__' || seg === 'constructor' || seg === 'prototype') {
|
|
297
|
+
ok = false;
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
if (!Object.prototype.hasOwnProperty.call(cur, seg) || cur[seg] === null) {
|
|
301
|
+
cur[seg] = {};
|
|
302
|
+
}
|
|
303
|
+
if (typeof cur[seg] !== 'object' || Array.isArray(cur[seg])) {
|
|
304
|
+
ok = false;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
cur = cur[seg];
|
|
308
|
+
}
|
|
309
|
+
if (!ok)
|
|
310
|
+
continue;
|
|
311
|
+
const leafKey = parts[parts.length - 1];
|
|
312
|
+
// S2: inline literal guard on leaf
|
|
313
|
+
if (leafKey === '__proto__' || leafKey === 'constructor' || leafKey === 'prototype')
|
|
314
|
+
continue;
|
|
315
|
+
if (!Object.prototype.hasOwnProperty.call(cur, leafKey)) {
|
|
316
|
+
cur[leafKey] = values[dottedKey];
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* FIX 2: Apply the federated overlay to a base config object.
|
|
323
|
+
* When validKeys is empty (current registry — all keys are central),
|
|
324
|
+
* returns the baseConfig UNCHANGED (true no-op, preserves reference identity).
|
|
325
|
+
* When validKeys is non-empty, applies values into a shallow clone to avoid
|
|
326
|
+
* mutating shared CONFIG_DEFAULTS/module constants.
|
|
327
|
+
*/
|
|
328
|
+
function _applyFederatedOverlay(baseConfig, userConfig) {
|
|
329
|
+
const _fedRegistrySchema = _capabilityRegistry.configSchema;
|
|
330
|
+
if (!_fedRegistrySchema || typeof _fedRegistrySchema !== 'object')
|
|
331
|
+
return baseConfig;
|
|
332
|
+
const _fedOverlay = mergeFederatedConfig({
|
|
333
|
+
configSchema: _fedRegistrySchema,
|
|
334
|
+
isCentralKey: (key) => _isValidConfigKeyFn(key),
|
|
335
|
+
userConfig,
|
|
336
|
+
});
|
|
337
|
+
// True no-op: if no federated keys, return UNCHANGED (byte-identical, no clone)
|
|
338
|
+
if (_fedOverlay.validKeys.length === 0)
|
|
339
|
+
return baseConfig;
|
|
340
|
+
// Clone shallowly to avoid mutating shared constants, then apply nested values
|
|
341
|
+
const cloned = { ...baseConfig };
|
|
342
|
+
_applyFederatedValues(cloned, _fedOverlay.values, _fedOverlay.validKeys);
|
|
343
|
+
return cloned;
|
|
344
|
+
}
|
|
345
|
+
function loadConfig(cwd, options = {}) {
|
|
346
|
+
const activeWorkstream = Object.prototype.hasOwnProperty.call(options, 'workstream')
|
|
347
|
+
? options['workstream']
|
|
348
|
+
: (options['workstreamContext'] && Object.prototype.hasOwnProperty.call(options['workstreamContext'], 'ws'))
|
|
349
|
+
? options['workstreamContext']['ws']
|
|
350
|
+
: (process.env['GSD_WORKSTREAM'] || null);
|
|
351
|
+
// When GSD_WORKSTREAM is set, load root config first so workstream config
|
|
352
|
+
// can inherit from it. This prevents users from duplicating model_overrides,
|
|
353
|
+
// workflow.*, etc. across every workstream config (#2714).
|
|
354
|
+
const ws = typeof activeWorkstream === 'string' ? activeWorkstream : (activeWorkstream === null ? null : null);
|
|
355
|
+
// #315 — per-call lazy memo: all three detection sites inside this loadConfig
|
|
356
|
+
// call operate on the same cwd and the subrepo set cannot change mid-call, so
|
|
357
|
+
// a single scan is sufficient. The memo is scoped to THIS call (not module-level)
|
|
358
|
+
// so separate loadConfig invocations each get a fresh scan.
|
|
359
|
+
let cachedSubRepos;
|
|
360
|
+
const getDetectedSubRepos = () => {
|
|
361
|
+
if (cachedSubRepos === undefined)
|
|
362
|
+
cachedSubRepos = detectSubRepos(cwd);
|
|
363
|
+
// Return a copy: original detectSubRepos returned a fresh array per call,
|
|
364
|
+
// so each site must keep an independent array (avoid cross-site aliasing).
|
|
365
|
+
return cachedSubRepos.slice();
|
|
366
|
+
};
|
|
367
|
+
let rootParsed = null;
|
|
368
|
+
if (ws) {
|
|
369
|
+
const rootConfigPath = node_path_1.default.join(planningRoot(cwd), 'config.json');
|
|
370
|
+
try {
|
|
371
|
+
const raw = (0, shell_command_projection_cjs_1.platformReadSync)(rootConfigPath);
|
|
372
|
+
if (raw === null)
|
|
373
|
+
throw new Error('missing');
|
|
374
|
+
rootParsed = JSON.parse(raw);
|
|
375
|
+
// Cycle 4: delegate all legacy-key normalization to the Configuration Module.
|
|
376
|
+
const { parsed: rootNormalized, normalizations: rootNorms } = (0, configuration_cjs_1.normalizeLegacyKeys)(rootParsed);
|
|
377
|
+
if (rootNorms.length > 0) {
|
|
378
|
+
// Resolve filesystem-dependent normalizations (multiRepo → planning.sub_repos)
|
|
379
|
+
for (const norm of rootNorms) {
|
|
380
|
+
if (norm.requiresFilesystem && !rootNormalized.planning?.['sub_repos']) {
|
|
381
|
+
const detected = getDetectedSubRepos();
|
|
382
|
+
if (detected.length > 0) {
|
|
383
|
+
if (!rootNormalized.planning)
|
|
384
|
+
rootNormalized.planning = {};
|
|
385
|
+
rootNormalized.planning['sub_repos'] = detected;
|
|
386
|
+
rootNormalized.planning['commit_docs'] = false;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
rootParsed = rootNormalized;
|
|
391
|
+
try {
|
|
392
|
+
(0, shell_command_projection_cjs_1.platformWriteSync)(rootConfigPath, JSON.stringify(rootParsed, null, 2));
|
|
393
|
+
}
|
|
394
|
+
catch { /* ignore */ }
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
rootParsed = rootNormalized;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
catch {
|
|
401
|
+
// Root config missing or unparseable — workstream config stands alone
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
const configPath = node_path_1.default.join(planningDir(cwd, ws), 'config.json');
|
|
405
|
+
const defaults = CONFIG_DEFAULTS;
|
|
406
|
+
try {
|
|
407
|
+
const raw = (0, shell_command_projection_cjs_1.platformReadSync)(configPath);
|
|
408
|
+
if (raw === null)
|
|
409
|
+
throw new Error('missing');
|
|
410
|
+
// `fileData` is the parsed content of the config.json file on disk — used
|
|
411
|
+
// for migrations and writes so we never persist merged values back to disk.
|
|
412
|
+
const fileData = JSON.parse(raw);
|
|
413
|
+
// Cycle 4: Single normalizeLegacyKeys call replaces all four inline migration
|
|
414
|
+
// blocks (depth→granularity, multiRepo→planning.sub_repos, sub_repos→planning.sub_repos,
|
|
415
|
+
// branching_strategy→git.branching_strategy). The Module is pure (no I/O); disk
|
|
416
|
+
// writeback is handled below with the existing platformWriteSync pattern.
|
|
417
|
+
let configDirty = false;
|
|
418
|
+
{
|
|
419
|
+
const { parsed: normalized, normalizations } = (0, configuration_cjs_1.normalizeLegacyKeys)(fileData);
|
|
420
|
+
if (normalizations.length > 0) {
|
|
421
|
+
// Merge normalized values back into fileData (mutation-in-place for legacy code below)
|
|
422
|
+
Object.keys(fileData).forEach(k => delete fileData[k]);
|
|
423
|
+
Object.assign(fileData, normalized);
|
|
424
|
+
configDirty = true;
|
|
425
|
+
// Resolve filesystem-dependent normalizations (multiRepo → planning.sub_repos).
|
|
426
|
+
for (const norm of normalizations) {
|
|
427
|
+
if (norm.requiresFilesystem && !fileData.planning?.['sub_repos']) {
|
|
428
|
+
const detected = getDetectedSubRepos();
|
|
429
|
+
if (detected.length > 0) {
|
|
430
|
+
if (!fileData.planning)
|
|
431
|
+
fileData.planning = {};
|
|
432
|
+
fileData.planning['sub_repos'] = detected;
|
|
433
|
+
fileData.planning['commit_docs'] = false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// Keep planning.sub_repos in sync with actual filesystem
|
|
440
|
+
const currentSubRepos = fileData.planning?.['sub_repos'] || [];
|
|
441
|
+
if (Array.isArray(currentSubRepos) && currentSubRepos.length > 0) {
|
|
442
|
+
const detected = getDetectedSubRepos();
|
|
443
|
+
if (detected.length > 0) {
|
|
444
|
+
const sorted = [...currentSubRepos].sort();
|
|
445
|
+
if (JSON.stringify(sorted) !== JSON.stringify(detected)) {
|
|
446
|
+
if (!fileData.planning)
|
|
447
|
+
fileData.planning = {};
|
|
448
|
+
fileData.planning['sub_repos'] = detected;
|
|
449
|
+
configDirty = true;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
// Persist sub_repos changes (migration or sync) — write only the on-disk
|
|
454
|
+
// file contents, never the merged result, to avoid polluting workstream configs.
|
|
455
|
+
if (configDirty) {
|
|
456
|
+
try {
|
|
457
|
+
(0, shell_command_projection_cjs_1.platformWriteSync)(configPath, JSON.stringify(fileData, null, 2));
|
|
458
|
+
}
|
|
459
|
+
catch { /* ignore */ }
|
|
460
|
+
}
|
|
461
|
+
// Now apply root→workstream inheritance. `parsed` is the effective config
|
|
462
|
+
// used for value extraction below; fileData is kept for disk writes only.
|
|
463
|
+
const parsed = rootParsed
|
|
464
|
+
? (_deepMergeConfig(rootParsed, fileData) ?? fileData)
|
|
465
|
+
: fileData;
|
|
466
|
+
// Warn about unrecognized top-level keys so users don't silently lose config.
|
|
467
|
+
const KNOWN_TOP_LEVEL = new Set([
|
|
468
|
+
// Extract top-level key names from dot-notation paths (e.g., 'workflow.research' → 'workflow')
|
|
469
|
+
...[...VALID_CONFIG_KEYS].map((k) => k.split('.')[0]),
|
|
470
|
+
// Dynamic-pattern top-level containers (e.g. review, model_profile_overrides)
|
|
471
|
+
...DYNAMIC_KEY_PATTERNS.map(p => p.topLevel),
|
|
472
|
+
// Internal keys loadConfig reads but config-set doesn't expose
|
|
473
|
+
'model_overrides', 'context_window', 'resolve_model_ids', 'claude_md_path', 'effort', 'fast_mode',
|
|
474
|
+
// Deprecated keys (still accepted for migration, not in config-set)
|
|
475
|
+
'depth', 'multiRepo', 'branching_strategy',
|
|
476
|
+
]);
|
|
477
|
+
// FIX 3: Compute federated overlay BEFORE the unknown-key warning, so that
|
|
478
|
+
// federated top-level keys are added to KNOWN_TOP_LEVEL before the check runs.
|
|
479
|
+
// This is hoisted out of the try-catch below so validKeys are available here.
|
|
480
|
+
let _preWarningFedValidKeys = [];
|
|
481
|
+
try {
|
|
482
|
+
const _fedRegistrySchemaEarly = _capabilityRegistry.configSchema;
|
|
483
|
+
if (_fedRegistrySchemaEarly && typeof _fedRegistrySchemaEarly === 'object') {
|
|
484
|
+
const _earlyOverlay = mergeFederatedConfig({
|
|
485
|
+
configSchema: _fedRegistrySchemaEarly,
|
|
486
|
+
isCentralKey: (key) => _isValidConfigKeyFn(key),
|
|
487
|
+
userConfig: parsed,
|
|
488
|
+
});
|
|
489
|
+
_preWarningFedValidKeys = _earlyOverlay.validKeys;
|
|
490
|
+
for (const dottedKey of _preWarningFedValidKeys) {
|
|
491
|
+
const topKey = dottedKey.split('.')[0];
|
|
492
|
+
if (topKey !== '__proto__' && topKey !== 'constructor' && topKey !== 'prototype') {
|
|
493
|
+
KNOWN_TOP_LEVEL.add(topKey);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
catch {
|
|
499
|
+
// Defensive: if registry access fails here, proceed without pre-warning keys
|
|
500
|
+
}
|
|
501
|
+
const unknownKeys = Object.keys(parsed).filter(k => !KNOWN_TOP_LEVEL.has(k));
|
|
502
|
+
if (unknownKeys.length > 0) {
|
|
503
|
+
const warnKey = unknownKeys.join(',');
|
|
504
|
+
if (!_warnedUnknownConfigKeys.has(warnKey)) {
|
|
505
|
+
_warnedUnknownConfigKeys.add(warnKey);
|
|
506
|
+
process.stderr.write(`gsd-tools: warning: unknown config key(s) in .planning/config.json: ${unknownKeys.join(', ')} — these will be ignored\n`);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
// #2517 — Validate runtime/tier values
|
|
510
|
+
_warnUnknownProfileOverrides(parsed, '.planning/config.json');
|
|
511
|
+
const get = (key, nested) => {
|
|
512
|
+
if (parsed[key] !== undefined)
|
|
513
|
+
return parsed[key];
|
|
514
|
+
if (nested && parsed[nested.section] && typeof parsed[nested.section] === 'object' && parsed[nested.section] !== null) {
|
|
515
|
+
const sec = parsed[nested.section];
|
|
516
|
+
if (sec[nested.field] !== undefined) {
|
|
517
|
+
return sec[nested.field];
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return undefined;
|
|
521
|
+
};
|
|
522
|
+
const parallelization = (() => {
|
|
523
|
+
const val = get('parallelization');
|
|
524
|
+
if (typeof val === 'boolean')
|
|
525
|
+
return val;
|
|
526
|
+
if (typeof val === 'object' && val !== null && 'enabled' in (val))
|
|
527
|
+
return val['enabled'];
|
|
528
|
+
return defaults.parallelization;
|
|
529
|
+
})();
|
|
530
|
+
const _baseConfig = {
|
|
531
|
+
model_profile: get('model_profile') ?? defaults.model_profile,
|
|
532
|
+
commit_docs: (() => {
|
|
533
|
+
const explicit = get('commit_docs', { section: 'planning', field: 'commit_docs' });
|
|
534
|
+
// If explicitly set in config, respect the user's choice
|
|
535
|
+
if (explicit !== undefined)
|
|
536
|
+
return explicit;
|
|
537
|
+
// Auto-detection: when no explicit value and .planning/ is gitignored,
|
|
538
|
+
// default to false instead of true
|
|
539
|
+
if (isGitIgnored(cwd, '.planning/'))
|
|
540
|
+
return false;
|
|
541
|
+
return defaults.commit_docs;
|
|
542
|
+
})(),
|
|
543
|
+
search_gitignored: get('search_gitignored', { section: 'planning', field: 'search_gitignored' }) ?? defaults.search_gitignored,
|
|
544
|
+
branching_strategy: get('branching_strategy', { section: 'git', field: 'branching_strategy' }) ?? defaults.branching_strategy,
|
|
545
|
+
phase_branch_template: get('phase_branch_template', { section: 'git', field: 'phase_branch_template' }) ?? defaults.phase_branch_template,
|
|
546
|
+
milestone_branch_template: get('milestone_branch_template', { section: 'git', field: 'milestone_branch_template' }) ?? defaults.milestone_branch_template,
|
|
547
|
+
quick_branch_template: get('quick_branch_template', { section: 'git', field: 'quick_branch_template' }) ?? defaults.quick_branch_template,
|
|
548
|
+
research: get('research', { section: 'workflow', field: 'research' }) ?? defaults.research,
|
|
549
|
+
plan_checker: get('plan_checker', { section: 'workflow', field: 'plan_check' }) ?? defaults.plan_checker,
|
|
550
|
+
verifier: get('verifier', { section: 'workflow', field: 'verifier' }) ?? defaults.verifier,
|
|
551
|
+
nyquist_validation: get('nyquist_validation', { section: 'workflow', field: 'nyquist_validation' }) ?? defaults.nyquist_validation,
|
|
552
|
+
post_planning_gaps: get('post_planning_gaps', { section: 'workflow', field: 'post_planning_gaps' }) ?? defaults.post_planning_gaps,
|
|
553
|
+
parallelization,
|
|
554
|
+
brave_search: get('brave_search') ?? defaults.brave_search,
|
|
555
|
+
firecrawl: get('firecrawl') ?? defaults.firecrawl,
|
|
556
|
+
exa_search: get('exa_search') ?? defaults.exa_search,
|
|
557
|
+
tdd_mode: get('tdd_mode', { section: 'workflow', field: 'tdd_mode' }) ?? false,
|
|
558
|
+
mvp_mode: get('mvp_mode', { section: 'workflow', field: 'mvp_mode' }) ?? false,
|
|
559
|
+
text_mode: get('text_mode', { section: 'workflow', field: 'text_mode' }) ?? defaults.text_mode,
|
|
560
|
+
auto_advance: get('auto_advance', { section: 'workflow', field: 'auto_advance' }) ?? false,
|
|
561
|
+
_auto_chain_active: get('_auto_chain_active', { section: 'workflow', field: '_auto_chain_active' }) ?? false,
|
|
562
|
+
mode: get('mode') ?? 'interactive',
|
|
563
|
+
sub_repos: get('sub_repos', { section: 'planning', field: 'sub_repos' }) ?? defaults.sub_repos,
|
|
564
|
+
resolve_model_ids: get('resolve_model_ids') ?? defaults.resolve_model_ids,
|
|
565
|
+
context_window: get('context_window') ?? defaults.context_window,
|
|
566
|
+
phase_naming: get('phase_naming') ?? defaults.phase_naming,
|
|
567
|
+
project_code: get('project_code') ?? defaults.project_code,
|
|
568
|
+
subagent_timeout: get('subagent_timeout', { section: 'workflow', field: 'subagent_timeout' }) ?? defaults.subagent_timeout,
|
|
569
|
+
model_overrides: (parsed['model_overrides']) || null,
|
|
570
|
+
// #3023 — per-phase-type model map.
|
|
571
|
+
models: (parsed['models']) || null,
|
|
572
|
+
// #68 — top-level granularity
|
|
573
|
+
granularity: parsed['granularity'] !== undefined ? parsed['granularity'] : null,
|
|
574
|
+
// #68 — per-phase-type granularity map.
|
|
575
|
+
granularities: (parsed['granularities']) || null,
|
|
576
|
+
// #68 — planning sub-object
|
|
577
|
+
planning: (parsed['planning']) || null,
|
|
578
|
+
// #3024 — dynamic routing block.
|
|
579
|
+
dynamic_routing: (parsed['dynamic_routing']) || null,
|
|
580
|
+
// #2517 — runtime-aware profiles.
|
|
581
|
+
runtime: (parsed['runtime']) || null,
|
|
582
|
+
model_profile_overrides: (parsed['model_profile_overrides']) || null,
|
|
583
|
+
// #49 — provider-neutral model policy presets.
|
|
584
|
+
model_policy: (parsed['model_policy']) || null,
|
|
585
|
+
// #443 — effort/fast_mode
|
|
586
|
+
effort: (parsed['effort']) || null,
|
|
587
|
+
fast_mode: (parsed['fast_mode']) || null,
|
|
588
|
+
agent_skills: (parsed['agent_skills']) || {},
|
|
589
|
+
agent_skills_security: (parsed['agent_skills_security']) || null,
|
|
590
|
+
manager: (parsed['manager']) || {},
|
|
591
|
+
response_language: get('response_language') || null,
|
|
592
|
+
claude_md_path: get('claude_md_path') || null,
|
|
593
|
+
claude_md_assembly: (parsed['claude_md_assembly']) || null,
|
|
594
|
+
};
|
|
595
|
+
// ─── ADR-857 phase 3b: federated config overlay ───────────────────────────
|
|
596
|
+
// FIX 2: Use the pre-computed _preWarningFedValidKeys (from the FIX 3 block above)
|
|
597
|
+
// plus a fresh overlay call to get values. The KNOWN_TOP_LEVEL was already updated.
|
|
598
|
+
// TODAY: every UI key is still in the central config-schema, so isCentralKey()
|
|
599
|
+
// returns true for all of them → validKeys is empty → _baseConfig is returned UNCHANGED
|
|
600
|
+
// (true no-op: no clone, no reorder, byte-identical output).
|
|
601
|
+
// This becomes a live channel once a key is atomically removed from the central schema.
|
|
602
|
+
try {
|
|
603
|
+
if (_preWarningFedValidKeys.length > 0) {
|
|
604
|
+
// There are actual federated values — re-use the already-computed overlay
|
|
605
|
+
// (we run mergeFederatedConfig again here to get the values map; the validKeys
|
|
606
|
+
// are guaranteed identical since it's the same inputs).
|
|
607
|
+
const _fedRegistrySchema = _capabilityRegistry.configSchema;
|
|
608
|
+
if (_fedRegistrySchema && typeof _fedRegistrySchema === 'object') {
|
|
609
|
+
const _fedOverlay = mergeFederatedConfig({
|
|
610
|
+
configSchema: _fedRegistrySchema,
|
|
611
|
+
isCentralKey: (key) => _isValidConfigKeyFn(key),
|
|
612
|
+
userConfig: parsed,
|
|
613
|
+
});
|
|
614
|
+
// Apply dotted-path values (e.g. "workflow.ui_phase" → _baseConfig.workflow.ui_phase)
|
|
615
|
+
// WITHOUT clobbering existing keys. N-level nesting supported.
|
|
616
|
+
_applyFederatedValues(_baseConfig, _fedOverlay.values, _fedOverlay.validKeys);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
// Pending-migration warnings are suppressed at load time to avoid noisy output on
|
|
620
|
+
// every loadConfig call. They are surfaced at registry-generation time (--check/--write).
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
// Defensive: if the federated overlay throws for any reason, return the base config unchanged.
|
|
624
|
+
// This keeps loadConfig's no-throw contract intact regardless of capability registry state.
|
|
625
|
+
}
|
|
626
|
+
return _baseConfig;
|
|
627
|
+
}
|
|
628
|
+
catch {
|
|
629
|
+
// Fall back to ~/.gsd/defaults.json only for truly pre-project contexts (#1683)
|
|
630
|
+
if (node_fs_1.default.existsSync(planningDir(cwd, ws))) {
|
|
631
|
+
if (rootParsed) {
|
|
632
|
+
// Workstream has no config.json: re-parse using root config as the sole source.
|
|
633
|
+
// (FIX 2: overlay is applied recursively in the re-entrant loadConfig call)
|
|
634
|
+
return loadConfig(cwd, { workstream: null });
|
|
635
|
+
}
|
|
636
|
+
// FIX 2: Apply the federated overlay on the no-config path.
|
|
637
|
+
// With the current registry (all keys central), _applyFederatedOverlay returns
|
|
638
|
+
// `defaults` UNCHANGED (true no-op, preserves byte-identical output).
|
|
639
|
+
try {
|
|
640
|
+
return _applyFederatedOverlay(defaults, {});
|
|
641
|
+
}
|
|
642
|
+
catch {
|
|
643
|
+
return defaults;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
try {
|
|
647
|
+
const home = process.env['GSD_HOME'] || node_os_1.default.homedir();
|
|
648
|
+
const globalDefaultsPath = node_path_1.default.join(home, '.gsd', 'defaults.json');
|
|
649
|
+
const raw = (0, shell_command_projection_cjs_1.platformReadSync)(globalDefaultsPath);
|
|
650
|
+
if (raw === null)
|
|
651
|
+
throw new Error('missing');
|
|
652
|
+
const globalDefaults = JSON.parse(raw);
|
|
653
|
+
const _globalBaseCfg = {
|
|
654
|
+
...defaults,
|
|
655
|
+
model_profile: (globalDefaults['model_profile']) ?? defaults.model_profile,
|
|
656
|
+
commit_docs: (globalDefaults['commit_docs']) ?? defaults.commit_docs,
|
|
657
|
+
research: (globalDefaults['research']) ?? defaults.research,
|
|
658
|
+
plan_checker: (globalDefaults['plan_checker']) ?? defaults.plan_checker,
|
|
659
|
+
verifier: (globalDefaults['verifier']) ?? defaults.verifier,
|
|
660
|
+
nyquist_validation: (globalDefaults['nyquist_validation']) ?? defaults.nyquist_validation,
|
|
661
|
+
post_planning_gaps: (globalDefaults['post_planning_gaps'])
|
|
662
|
+
?? globalDefaults['workflow']?.['post_planning_gaps']
|
|
663
|
+
?? defaults.post_planning_gaps,
|
|
664
|
+
parallelization: (globalDefaults['parallelization']) ?? defaults.parallelization,
|
|
665
|
+
text_mode: (globalDefaults['text_mode']) ?? defaults.text_mode,
|
|
666
|
+
resolve_model_ids: (globalDefaults['resolve_model_ids']) ?? defaults.resolve_model_ids,
|
|
667
|
+
context_window: (globalDefaults['context_window']) ?? defaults.context_window,
|
|
668
|
+
subagent_timeout: (globalDefaults['subagent_timeout']) ?? defaults.subagent_timeout,
|
|
669
|
+
model_overrides: (globalDefaults['model_overrides']) || null,
|
|
670
|
+
models: (globalDefaults['models']) || null,
|
|
671
|
+
granularity: (globalDefaults['granularity']) !== undefined ? globalDefaults['granularity'] : null,
|
|
672
|
+
granularities: (globalDefaults['granularities']) || null,
|
|
673
|
+
planning: (globalDefaults['planning']) || null,
|
|
674
|
+
dynamic_routing: (globalDefaults['dynamic_routing']) || null,
|
|
675
|
+
effort: (globalDefaults['effort']) || null,
|
|
676
|
+
fast_mode: (globalDefaults['fast_mode']) || null,
|
|
677
|
+
agent_skills: (globalDefaults['agent_skills']) || {},
|
|
678
|
+
response_language: (globalDefaults['response_language']) || null,
|
|
679
|
+
};
|
|
680
|
+
// FIX 2: Apply federated overlay on global-defaults path.
|
|
681
|
+
// With the current registry this is a true no-op (returns _globalBaseCfg unchanged).
|
|
682
|
+
try {
|
|
683
|
+
return _applyFederatedOverlay(_globalBaseCfg, globalDefaults);
|
|
684
|
+
}
|
|
685
|
+
catch {
|
|
686
|
+
return _globalBaseCfg;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
catch {
|
|
690
|
+
// FIX 2: Apply federated overlay on the final fallback path.
|
|
691
|
+
// With the current registry this is a true no-op (returns `defaults` unchanged).
|
|
692
|
+
try {
|
|
693
|
+
return _applyFederatedOverlay(defaults, {});
|
|
694
|
+
}
|
|
695
|
+
catch {
|
|
696
|
+
return defaults;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
module.exports = {
|
|
702
|
+
loadConfig,
|
|
703
|
+
isGitIgnored,
|
|
704
|
+
CONFIG_DEFAULTS,
|
|
705
|
+
_getConfigDefault,
|
|
706
|
+
_getNestedConfigDefault,
|
|
707
|
+
_deepMergeConfig,
|
|
708
|
+
_warnedUnknownConfigKeys,
|
|
709
|
+
_warnUnknownProfileOverrides,
|
|
710
|
+
_resetRuntimeWarningCacheForTests,
|
|
711
|
+
_warnedConfigKeys,
|
|
712
|
+
_gitIgnoredCache,
|
|
713
|
+
RUNTIME_OVERRIDE_TIERS,
|
|
714
|
+
_setFederatedRegistryForTests,
|
|
715
|
+
_resetFederatedRegistryForTests,
|
|
716
|
+
};
|