Commit Graph

20 Commits

Author SHA1 Message Date
Tom Boucher
5f521e0867 fix(settings): route /gsd-settings reads/writes through workstream-aware config path (#2285)
settings.md was reading and writing .planning/config.json directly while
gsd-tools config-get/config-set route to .planning/workstreams/<slug>/config.json
when GSD_WORKSTREAM is active, causing silent write-read drift (Closes #2282).

- config.cjs: add cmdConfigPath() — emits the planningDir-resolved config path as
  plain text (always raw, no JSON wrapping) so shell substitution works correctly
- gsd-tools.cjs: wire config-path subcommand
- settings.md: resolve GSD_CONFIG_PATH via config-path in ensure_and_load_config;
  replace hardcoded cat .planning/config.json and Write to .planning/config.json
  with $GSD_CONFIG_PATH throughout
- phase.cjs: fix renameDecimalPhases to preserve zero-padded prefix (06.3 → 06.2
  not 6.2) — pre-existing test failure on main
- tests/config.test.cjs: add config-path command tests (#2282)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 16:46:10 -04:00
Andreas Brauchli
2a08f11f46 fix(config): allow intel.enabled in config-set whitelist (#2021)
`intel.enabled` is the documented opt-in for the intel subsystem
(see commands/gsd/intel.md and docs/CONFIGURATION.md), but it was
missing from VALID_CONFIG_KEYS in config.cjs, so the canonical
command failed:

  $ gsd-tools config-set intel.enabled true
  Error: Unknown config key: "intel.enabled"

Add the key to the whitelist, document it under a new "Intel Fields"
section in planning-config.md alongside the other namespaced fields,
and cover it with a config-set test.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 15:00:38 -04:00
Rezolv
e107b4e225 feat(config): add execution context profiles for mode-specific agent output (#1827)
* feat(config): add execution context profiles for mode-specific agent output

* fix(config): add enum validation for context config key

Validate context values against allowed enum (dev, research, review)
in cmdConfigSet before writing to config.json, matching the pattern
used for model_profile validation. Add rejection test for invalid
context values.
2026-04-05 19:09:19 -04:00
Tom Boucher
2703422be8 refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md (#1675)
* refactor(tests): standardize to node:assert/strict and t.after() per CONTRIBUTING.md

- Replace require('node:assert') with require('node:assert/strict') across
  all 73 test files to enforce strict equality (no type coercion)
- Replace try/finally cleanup blocks with t.after() hooks in core.test.cjs
  and hooks-opt-in.test.cjs per the test lifecycle standards
- Utility functions in codex-config and security-scan retain try/finally
  as that is appropriate for per-function resource guards, not lifecycle hooks

Closes #1674

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* perf(tests): add --test-concurrency=4 to test runner for parallel file execution

Node.js --test-concurrency controls how many test files run as parallel child
processes. Set to 4 by default, configurable via TEST_CONCURRENCY env var.
Fixes tests at a known level rather than inheriting os.availableParallelism()
which varies across CI environments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(security): allowlist verify.test.cjs in prompt-injection scanner

tests/verify.test.cjs uses <human>...</human> as GSD phase task-type
XML (meaning "a human should verify this step"), which matches the
scanner's fake-message-boundary pattern for LLM APIs. This is a
false positive — add it to the allowlist alongside the other test files
that legitimately contain injection-adjacent patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 14:29:03 -04:00
Tibsfox
3cf5355c8c test(config): add config-get tests for git.base_branch
Add two config-get tests to verify the git.base_branch round-trip:
- config-get returns the value after config-set stores it
- config-get errors with "Key not found" when git.base_branch is not
  explicitly set (default config omits it), which triggers the
  auto-detect fallback via origin/HEAD in workflows

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 14:56:55 -07:00
Tibsfox
0fb992d151 fix(git): add git.base_branch config to replace hardcoded main target
Adds `git.base_branch` config option that controls the target branch
for PRs and merges. When unset, auto-detects from origin/HEAD and
falls back to "main".

This fixes projects using `master`, `develop`, or any other default
branch — previously `/gsd:ship` would create PRs targeting `main`
(which may not exist) and `/gsd:complete-milestone` would try to
checkout `main` and fail.

Changes:
- config.cjs: add git.base_branch to valid config keys
- planning-config.md: document the option with auto-detect behavior
- ship.md: detect base branch at init, use in PR create, branch
  detection, push report, and completion report
- complete-milestone.md: detect base branch, use for squash merge
  and merge-with-history checkout targets
- 1 new test for config-set git.base_branch

Usage:
  gsd-tools config-set git.base_branch master

Or auto-detect (default — reads origin/HEAD):
  git.base_branch: null

Closes #1466

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 14:56:55 -07:00
Tibsfox
74cd8f2bd0 test(config): add config-get/set roundtrip and cross-workflow structural tests for use_worktrees
Add comprehensive test coverage for the workflow.use_worktrees config toggle:
- config-get returns false after setting to false (roundtrip verification)
- config-get errors with "Key not found" when not set (validates workflow
  fallback behavior where `|| echo "true"` provides the default)
- config-get returns true after setting to true
- Toggle back and forth works correctly
- Structural tests verify USE_WORKTREES is wired into quick.md,
  diagnose-issues.md, execute-plan.md, planning-config.md, and config.cjs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 14:42:08 -07:00
Tibsfox
d1ff0437f1 feat(config): add workflow.use_worktrees toggle to disable worktree isolation
Adds `workflow.use_worktrees` config option (default: `true`) that
allows users to disable git worktree isolation for executor agents.

When set to `false`:
- Executor agents run without `isolation="worktree"`
- Plans execute sequentially on the main working tree
- No worktree merge ordering issues or orphaned worktrees
- Normal git hooks run (no --no-verify needed)

This provides an escape hatch for solo developers and users who
experience worktree merge conflicts, as worktree ordering issues
are inherently difficult when parallel agents modify overlapping
files.

Usage:
  /gsd:settings → set workflow.use_worktrees to false

Or directly:
  gsd-tools config-set workflow.use_worktrees false

Changes:
- config.cjs: add workflow.use_worktrees to valid keys
- planning-config.md: document the option
- execute-phase.md: read config, conditional worktree + sequential mode
- execute-plan.md: conditional worktree in Pattern A
- quick.md: conditional worktree for quick executor
- diagnose-issues.md: conditional worktree for debug agents
- 2 new tests (config set + workflow structural check)

Closes #1451

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 10:11:49 -07:00
Tom Boucher
616c1fa753 refactor: replace try/finally with beforeEach/afterEach + add CONTRIBUTING.md
Test suite modernization:
- Converted all try/finally cleanup patterns to beforeEach/afterEach hooks
  across 11 test files (core, copilot-install, config, workstream,
  milestone-summary, forensics, state, antigravity, profile-pipeline,
  workspace)
- Consolidated 40 inline mkdtempSync calls to use centralized helpers
- Added createTempDir() helper for bare temp directories
- Added optional prefix parameter to createTempProject/createTempGitProject
- Fixed config test HOME sandboxing (was reading global defaults.json)

New CONTRIBUTING.md:
- Test standards: hooks over try/finally, centralized helpers, HOME sandboxing
- Node 22/24 compatibility requirements with Node 26 forward-compat
- Code style, PR guidelines, security practices
- File structure overview

All 1382 tests pass, 0 failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:45:39 -04:00
Tom Boucher
2b31a8d3e1 feat: add workflow.skip_discuss setting to bypass discuss-phase in autonomous mode
When enabled, /gsd:autonomous chains directly from plan-phase to execute-phase,
skipping smart discuss. A minimal CONTEXT.md is auto-generated from the ROADMAP
phase goal so downstream agents have valid input. Manual /gsd:discuss-phase still
works regardless of the setting.

Changes:
- config.cjs: add workflow.skip_discuss to VALID_CONFIG_KEYS and hardcoded defaults (false)
- autonomous.md: check workflow.skip_discuss before smart_discuss, write minimal CONTEXT.md when skipping
- settings.md: add Skip Discuss toggle to interactive settings UI and global defaults
- config.test.cjs: 6 regression tests for the new config key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 18:13:31 -04:00
Tom Boucher
3306a77a79 fix: prevent discuss-phase from ignoring workflow instructions (#1292)
The discuss-phase command file contained a 93-line detailed <process>
block that competed with the actual workflow file. The agent treated
this summary as complete instructions and never read the execution_context
files (discuss-phase.md, discuss-phase-assumptions.md, context.md template).

Root cause: Unlike execute-phase and plan-phase commands (which have short
2-line process blocks deferring to the workflow file), discuss-phase had
inline step-by-step instructions detailed enough to act on without reading
the referenced workflow files.

Changes:
- Replace discuss-phase command's <process> block with a short directive
  that forces reading the workflow file, matching execute-phase/plan-phase
  pattern
- Add MANDATORY instruction that execution_context files ARE the
  instructions, not optional reading
- Register workflow.research_before_questions and workflow.discuss_mode
  as valid config keys (were missing from VALID_CONFIG_KEYS)
- Fix config key mismatch: workflows referenced "research_questions"
  but documented key is "workflow.research_before_questions"
- Move research_before_questions from hooks section to workflow section
  in settings workflow
- Add research_before_questions default to config template and builder
- Add suggestion mapping for deprecated hooks.research_questions key
- Add 6 regression tests covering config keys and process block guard

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 14:13:11 -04:00
Diego Mariño
a1852fef33 fix(tests): add USERPROFILE override for Windows HOME sandboxing
On Windows, os.homedir() reads USERPROFILE instead of HOME. The 6
tests using { HOME: tmpDir } to sandbox ~/.gsd/ lookups failed on
windows-latest because the child process still resolved homedir to
the real user profile.

Pass USERPROFILE alongside HOME in all sandboxed test calls.
2026-03-20 14:56:28 +01:00
Diego Mariño
fd2a80675a merge: resolve conflicts with upstream main
VALID_CONFIG_KEYS: merge our additions (workflow.auto_advance,
workflow.node_repair, workflow.node_repair_budget, hooks.context_warnings)
with upstream's additions (workflow.text_mode, git.quick_branch_template).

ensureConfigFile(): keep our refactored version that delegates to
buildNewProjectConfig({}) instead of upstream's duplicated logic.

buildNewProjectConfig(): add git.quick_branch_template: null and
workflow.text_mode: false to match upstream's new keys.

new-project.md: integrate upstream's Step 5.1 Sub-Repo Detection
after our commit block; drop upstream's duplicate Note (ours at
line 493 is more detailed).
2026-03-19 22:48:21 +01:00
Tom Boucher
0487151142 fix(workflows): add text_mode config for Claude Code remote session compatibility (#1214)
- Add workflow.text_mode config option (default: false) that replaces
  AskUserQuestion TUI menus with plain-text numbered lists
- Document --text flag and config-set workflow.text_mode true as the
  fix for /rc remote sessions where the Claude App cannot forward TUI
  menu selections
- Update discuss-phase.md with text mode parsing and answer_validation
  fallback documentation
- Add text_mode to loadConfig defaults and VALID_CONFIG_KEYS
- Add regression tests for config-set and loadConfig
2026-03-19 09:19:01 -04:00
Diego Mariño
a1207d5473 fix(tests): make HOME sandboxing opt-in to avoid breaking git-dependent tests
The global HOME override in runGsdTools broke tests in verify-health.test.cjs
on Ubuntu CI: git operations fail when HOME points to a tmpDir that lacks
the runner's .gitconfig.

- runGsdTools now accepts an optional third `env` parameter (default: {})
  merged on top of process.env — no behavior change for callers that omit it
- Pass { HOME: tmpDir } only in the 6 tests that need ~/.gsd/ isolation:
  brave_api_key detection, defaults.json merging (x2), and config-new-project
  tests that assert concrete default values (x3)
2026-03-18 23:10:56 +01:00
Diego Mariño
63f6424d1b fix(tests): sandbox HOME in runGsdTools to prevent flaky assertions
buildNewProjectConfig() merges ~/.gsd/defaults.json when present, so
tests asserting concrete config values (model_profile, commit_docs,
brave_search) would fail on machines with a personal defaults file.

- Pass HOME=cwd as env override in runGsdTools — child process resolves
  os.homedir() to the temp directory, which has no .gsd/ subtree
- Update three tests that previously wrote to the real ~/.gsd/ using
  fragile save/restore logic; they now write to tmpDir/.gsd/ instead,
  which is cleaned up automatically by afterEach
- Remove now-unused `os` import from config.test.cjs
2026-03-18 15:27:46 +01:00
Diego Mariño
f649543b20 feat: materialize full config on new-project initialization
Add `config-new-project` CLI command that writes a complete,
fully-materialized `.planning/config.json` with sane defaults
instead of the previous partial template (6-7 user-chosen keys
only). Unset keys are no longer silently resolved at read time —
every key GSD reads is written explicitly at project creation.

Previously, missing keys were resolved silently by loadConfig()
defaults, making the effective config non-discoverable. Now every
key that GSD reads is written explicitly at project creation.

- buildNewProjectConfig() — single source of truth for all
  defaults; merges hardcoded ← ~/.gsd/defaults.json ← user choices
- ensureConfigFile() refactored to reuse buildNewProjectConfig({})
  instead of duplicating default logic (~40 lines removed)
- new-project.md Steps 2a and 5 updated to call config-new-project
  instead of writing a hardcoded partial JSON template
- Test coverage for config.cjs: 78.96% → 93.81% statements,
  100% functions; adds config-set-model-profile test suite

FIXES:
- VALID_CONFIG_KEYS extended with workflow.auto_advance,
  workflow.node_repair, workflow.node_repair_budget,
  hooks.context_warnings — these keys had hardcoded defaults
  but were not settable via config-set
2026-03-18 14:58:58 +01:00
Frank
63823c2e8a fix: skip no-research nyquist artifact gating (closes #980) 2026-03-15 10:08:57 -06:00
Fana
c81b20eb04 fix: plan-phase Nyquist validation when research is disabled (#980) (#1002)
* fix: plan-phase Nyquist validation when research is disabled (#980)

plan-phase step 5.5 required Nyquist artifacts even when research was
disabled, creating an impossible state: no RESEARCH.md to extract
Validation Architecture from. Step 7.5 then told Claude to "disable
Nyquist in config" without specifying the exact key, causing Claude to
guess wrong keys that config-set silently accepted.

Three fixes:
- plan-phase step 5.5: skip when research_enabled is false
- plan-phase step 7.5: specify exact config-set command for disabling
- config-set: reject unknown keys with whitelist validation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: update config-set tests for key whitelist validation

Tests that used arbitrary keys (some_number, some_string, a.b.c) now
use valid config keys to test the same coercion and nesting behavior.
Adds new test asserting unknown keys are rejected with error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 11:36:11 -06:00
Ethan Hurst
898b82dee0 fix(quick-1): remove MEDIUM severity test overfitting in config.test.cjs
- branching_strategy assertion changed from strictEqual 'none' to typeof string check
- plan_check and verifier assertions changed from strictEqual true to typeof boolean checks
- Add isolation comments to three tests that touch ~/.gsd/ on real filesystem
- Full test suite passes: 433 tests, all modules above 70% coverage
2026-02-26 05:49:31 +10:00