Commit graph

1736 commits

Author SHA1 Message Date
Derek Pearson
e706876114 fix(skills): add migration from ~/.gsd/agent/skills/ to ~/.agents/skills/
Existing GSD users have skills in ~/.gsd/agent/skills/ that would
silently vanish after the directory switch.  This adds:

1. One-time migration in initResources() — copies skill directories
   from ~/.gsd/agent/skills/ to ~/.agents/skills/ (collision-safe,
   writes .migrated-to-agents marker so it runs at most once).

2. Legacy fallback reads in loadSkills() and getSkillSearchDirs() —
   the old directory is scanned as a low-priority fallback so skills
   work immediately, even before the migration runs on next restart.

The old directory is NOT deleted — users can safely downgrade to a
pre-migration GSD version without losing skills.
2026-03-22 05:30:29 -04:00
Derek Pearson
4020828260 feat(skills): parse SDKROOT from pbxproj for platform-aware iOS skill matching
Replace boolean hasXcodeProject with xcodePlatforms array that reads
SDKROOT values from *.xcodeproj/project.pbxproj files. iOS skill packs
now only match when SDKROOT=iphoneos, so macOS / watchOS / visionOS /
tvOS Xcode projects won't get iOS-specific skills.

Also splits the monolithic "Swift / iOS" pack into 8 granular bundles
matching dpearson2699/swift-ios-skills plugin structure:
  - SwiftUI + Swift Core (any Swift project)
  - iOS App Frameworks, Data Frameworks, AI & ML, Engineering,
    Hardware, Platform (iphoneos projects only)

Adds batched installation to minimize npx invocations when multiple
packs share the same repo.
2026-03-22 05:19:05 -04:00
Derek Pearson
aaed0ab796 feat(skills): use ~/.agents/skills/ as primary skills directory with curated catalog
Stop force-syncing bundled skills to ~/.gsd/agent/skills/ on every launch.
Instead, use ~/.agents/skills/ (the industry-standard skills.sh directory)
as the primary global skills location, and .agents/skills/ for project-local
skills.

Changes:
- loadSkills() now scans ~/.agents/skills/ (global) and .agents/skills/ (project)
  instead of ~/.gsd/agent/skills/ and .gsd/skills/
- initResources() no longer syncs src/resources/skills/ → ~/.gsd/agent/skills/
- skill-discovery, skill-telemetry, skill-health, preferences-skills all updated
  to use the ecosystem directory
- New skill-catalog.ts: curated skill packs mapped to tech stacks, with
  brownfield auto-detection and greenfield tech stack selection
- Init wizard gains a skill installation step that presents relevant packs
  and installs via `npx skills add`
- Export ECOSYSTEM_SKILLS_DIR and ECOSYSTEM_PROJECT_SKILLS_DIR from pi-coding-agent

Fixes #2004
2026-03-22 05:03:36 -04:00
Derek Pearson
3c9c6817dc Merge branch 'main' of https://github.com/gsd-build/gsd-2 2026-03-22 04:22:01 -04:00
Iouri Goussev
642c0f5a9e test: fix Assertion Roulette, Eager Test, and contract test regressions (#1938)
* test: add assertion messages to fix Assertion Roulette in GSD tests

Add descriptive messages to multi-assertion tests where a bare failure
output ("expected true, got false") wouldn't identify which assertion
broke. Affected tests: auto-secrets-gate, search-tavily, search-provider-
command, tavily-helpers.

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

* test: fix Eager Test smell in captures and worktree-manager tests

- Split captures: loadPendingCaptures test — extracted loadAllCaptures
  assertion into its own focused test
- Refactor worktree-manager: replace monolithic main() script with 11
  isolated test() calls, each with its own repo setup via helpers

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

* test: add assertion messages to remaining test files

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

* test: fix contract test gate, dynamic roots, and shared fetch helpers

- Fix reject-notice sub-test gated on outcome.kind (actual) instead of
  expectedKind (map value) in web-command-parity-contract.test.ts
- Restore dynamic loop over registered non-gsd passthrough roots with
  an explicit count assertion so new registrations fail loudly
- Extract normalizeHeaders/parseJsonBody to src/tests/fetch-test-helpers.ts
  and import in both search-tavily and llm-context-tavily tests

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

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 21:24:15 -06:00
djimenez18
32bbf07d0b Fix command for browser-based web interface (#1932)
Corrected the command for running GSD in the browser from 'pi --web' to 'gsd --web'.
2026-03-21 21:23:45 -06:00
Lex Christopherson
61e473b32c fix: add missing codeFilesChanged to journal integration test mock
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 21:12:38 -06:00
TÂCHES
d40ed851a2 fix(repo-identity): use native realpath on Windows to resolve 8.3 short paths (#1960)
Use realpathSync.native() on Windows in canonicalizeExistingPath to resolve
8.3 short names (RUNNER~1 → runneradmin). Fixes isInheritedRepo path
comparison failures on Windows CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 21:08:58 -06:00
Tom Boucher
09f3a5f970 fix(doctor): gate roadmap checkbox on summary existing on disk, not issue detection (#1915)
The roadmap-done condition checked whether the missing-summary issue was
detected in the issues array, but at fixLevel="task" the summary is
detected and never fixed (deferred via COMPLETION_TRANSITION_CODES).
This caused the roadmap checkbox to be marked without the summary on
disk, making deriveState() skip the summarizing phase and hard-stop at
validating-milestone.

Replace the issues.some() fallback with an existsSync re-check so the
roadmap is only marked when the summary actually exists — either
pre-existing or created earlier in the same doctor run.

Fixes #1910

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 21:06:53 -06:00
Tom Boucher
53d7350e0d fix: warn when milestone merge contains only metadata and no code (#1906) (#1927)
mergeMilestoneToMain now detects when the squash-merge commit contains
only .gsd/ metadata files and no actual code changes. The worktree
resolver surfaces a clear warning so users know the milestone summary
may describe planned work that was never implemented.

The complete-milestone prompt now requires the LLM to verify code
changes exist on the branch before declaring verification passed.

Fixes #1906

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 21:05:56 -06:00
TÂCHES
79e49aa413 fix(worktree): resolve 8.3 short paths and use shell mode for .bat hooks on Windows (#1956)
Resolve Windows 8.3 short paths (RUNNER~1 → runneradmin) via realpathSync.native()
and use shell mode for .bat/.cmd files in worktree post-create hooks. Fixes
pre-existing windows-portability CI failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 20:52:30 -06:00
Derek Pearson
c81e982c8c Merge branch 'main' of https://github.com/gsd-build/gsd-2 2026-03-21 22:16:41 -04:00
TÂCHES
60885610ac feat(gsd): unified rule registry, event journal, journal query tool, and tool naming convention (#1928)
Unify dispatch rules and hooks into a flat rule registry, add structured event journal with causal tracing, expose journal query as an LLM tool, and adopt gsd_concept_action tool naming.

- RuleRegistry class absorbs dispatch rules + hooks into UnifiedRule objects with common when/where/then shape
- post-unit-hooks.ts refactored from 524 lines → 90-line thin facade delegating to the registry
- Event journal emits structured JSONL events with per-iteration flowId grouping and causedBy chains
- gsd_journal_query LLM-callable tool for AI self-debugging of autonomous runs
- 4 DB tools renamed to gsd_concept_action pattern with backward-compatible aliases
- 164 new tests, zero regressions

Closes #1763, closes #1764, closes #1766

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 18:47:41 -06:00
Jeremy McSpadden
bdd1e765f5 feat(ci): PR risk checker — classify changed files by system and surface risk level (#1930) 2026-03-21 18:12:01 -06:00
Jeremy McSpadden
c1a35dd1b3 feat: ADR attribution — distinguish human vs agent vs collaborative decisions (#1830)
* feat: add made_by attribution field to decisions (human/agent/collaborative)

Add a 'made_by' field to the Decision type that tracks whether a
decision was made by the human, the agent, or collaboratively. This
enables ADR-style accountability — you can always tell who actually
made each call.

Schema:
- New DecisionMadeBy type: 'human' | 'agent' | 'collaborative'
- DB schema v3 → v4: ALTER TABLE decisions ADD COLUMN made_by
- Existing decisions default to 'agent' (backward compatible)
- DECISIONS.md gains a 'Made By' column
- Parser handles old 7-column format gracefully (defaults to 'agent')

Surfaces updated:
- gsd_save_decision tool accepts optional made_by parameter
- Markdown generator/parser round-trips the new column
- Prompt formatter shows attribution in LLM context
- Compact formatter includes made_by in pipe-separated output
- Worktree reconciliation includes made_by in conflict detection + merge

Tests: 476 assertions across 9 test suites, all passing.

* fix(gsd-db): resolve CI failures and address review findings

- Update memory-store.test.ts to expect schema version 4
- Recreate active_decisions view in v4 migration to pick up new made_by column
- Handle missing made_by column in older worktrees during reconciliation
- Optimize VALID_MADE_BY Set by moving it outside the parser loop

* fix(types): resolve missing made_by property errors in context-store and tests
2026-03-21 15:26:28 -06:00
Tom Boucher
f4db25b9b8 fix(web): persist auth token in sessionStorage to survive page refreshes (#1877)
Next.js 16 auto-detects web/proxy.ts as middleware, gating all /api/*
routes behind bearer token validation. The token was only cached in
memory (lost on page refresh) and extracted from the URL hash fragment
(cleared after first extraction). This caused 401 errors on page
refresh and broke the sendBeacon shutdown call which cannot set
custom headers.

Changes:
- Persist the auth token to sessionStorage after extracting from the
  URL fragment so it survives page refreshes within the same tab
- Fall back to sessionStorage when the URL hash is absent (refresh,
  bookmark without hash)
- Pass the auth token as a _token query parameter in the sendBeacon
  shutdown call since sendBeacon cannot set Authorization headers
- Add regression tests for token persistence, sessionStorage fallback,
  and sendBeacon authentication

Fixes #1851

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:25:27 -06:00
Iouri Goussev
e0011a897a test: replace shape-only assertions with value checks (#1875)
Several test files used assert.ok(Array.isArray(x)) or assert.ok(result)
patterns that verify structure/existence without checking actual values.
These pass even when the code returns wrong data.

- web-diagnostics-contract: Array.isArray() checks → deepEqual([], [])
  for fields constructed as empty; DoctorFixResult uses deepEqual(["fix1"])
  instead of Array.isArray + length; InstanceType<typeof GSDWorkspaceStore>
  for type assertions from dynamic import
- skill-lifecycle: computeStaleAvoidList → deepEqual(result, []) since
  nonexistent path must return empty
- blob-store: remove redundant assert.ok(retrieved) before deepEqual
- discovery-cache: assert.ok(entry) existence check → verify models[0].id

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 15:25:10 -06:00
Tom Boucher
747e29b9b4 fix: clean up SQUASH_MSG after squash-merge and guard worktree teardown against uncommitted changes (#1868)
Three changes to prevent data loss and persistent doctor errors in the
worktree merge-back lifecycle:

1. After nativeCommit in mergeMilestoneToMain, explicitly delete
   .git/SQUASH_MSG. The native libgit2 path and git commit -F - on
   some versions do not auto-remove it, causing doctor to report
   corrupt_merge_state on every run.

2. Before worktree removal (step 11), check for uncommitted changes
   and force a final auto-commit if dirty. This prevents code files
   written by task agents from being destroyed by git worktree remove.

3. Invalidate the nativeHasChanges 10-second cache before the
   post-unit auto-commit in auto-post-unit.ts. A stale false result
   causes autoCommit to skip staging entirely.

Fixes #1853

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:53 -06:00
Tom Boucher
99032444eb fix: populate RecoveryContext in hook unit supervision to prevent crash on stalled tool recovery (#1867)
The buildRecoveryContext callback in auto/phases.ts returned an empty
object instead of a valid RecoveryContext. When the idle watchdog detected
a stalled tool and called recoverTimedOutUnit, basePath was undefined,
causing join(undefined, ".gsd") to throw "The path argument must be of
type string. Received undefined". The error left the session permanently
hung because the unit promise was never resolved.

Fixes #1855

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:37 -06:00
Tom Boucher
f79de8a583 fix: resolve worktree path from git registry when .gsd/ symlink is shadowed (#1866)
When .gsd/ is a symlink to an external state directory, git registers
worktrees at the resolved (real) path. If syncStateToProjectRoot later
creates a real .gsd/ directory that shadows the symlink, worktreePath()
computes a local path that diverges from git's registered path. The
stale local directory passes existsSync but is not a git worktree, so
nativeWorktreeRemove fails silently.

removeWorktree now queries nativeWorktreeList to find the actual
git-registered path by matching on branch name before attempting
removal, falling back to the computed path if the lookup fails.

Fixes #1852

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:21 -06:00
Tom Boucher
2e04253c0b fix: resolve Node v24 web boot failure — ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING (#1864)
Node v24 forbids --experimental-strip-types for files under node_modules/.
When GSD is globally installed, all src/ files live under node_modules/gsd-pi/,
causing every subprocess worker to crash with ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING.

Bug 1: Extract resolveTypeStrippingFlag() into src/web/ts-subprocess-flags.ts.
When the package root is under node_modules/ and Node >= 22.7, the function
returns --experimental-transform-types (which handles node_modules paths).
All 15 service files and cli-entry.ts now call this function instead of
hardcoding --experimental-strip-types.

Bug 2: waitForBootReady() now tracks consecutive 5xx responses and aborts
after 3 in a row, including the response body in the error message.
Connection-level errors (transient during cold start) reset the counter.

Bug 3: The /api/boot route handler now wraps collectBootPayload() in
try/catch and returns { error: message } with status 500, matching the
error response pattern used by other API routes.

Fixes #1849

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:24:07 -06:00
Tom Boucher
7140ee0f53 feat: add /gsd fast command and gate service tier icon to supported models (#1848) (#1862)
Add `/gsd fast [on|off|flex|status]` command for toggling OpenAI service
tiers, with `supportsServiceTier()` gating so the status bar icon only
appears on models that actually support service tiers (gpt-5.4 variants).

Fixes #1848

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:23:54 -06:00
Iouri Goussev
0dd7176af6 test: replace shape-only assertions with value checks in preferences and routing-history (#1842)
- preferences.test.ts: hook config tests were testing Math.max/min and a
  locally-constructed Set (testing JS builtins, not production code); replaced
  with validatePreferences calls that exercise real clamping in
  preferences-validation.ts and action validation for pre_dispatch_hooks.
  assert.ok(prefs) existence checks replaced with assert.notEqual(prefs, null).
- routing-history.test.ts: removed assert.ok(history) and assert.ok(pattern)
  guards that only verified object existence; assertions now go directly to
  the values that matter.
2026-03-21 15:23:26 -06:00
Tom Boucher
b49cb8cbad fix(auto): broaden worktree health check to all ecosystems (#1860)
* fix(auto): use PROJECT_FILES from detection.ts in worktree health check

The worktree health check introduced in #1833 hard-coded package.json
and src/ as the only valid project markers, blocking auto-mode dispatch
for Rust (Cargo.toml), Go (go.mod), Python (pyproject.toml), and 14
other ecosystems. Replace the JS-centric heuristic with the shared
PROJECT_FILES array from detection.ts which already covers 17+
ecosystems.

Fixes #1843

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: update test assertion to match new project files message

The health check now says "no recognized project files" instead of
"no package.json or src/" after broadening to PROJECT_FILES.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:22:34 -06:00
Tom Boucher
358dc1da6b fix(doctor): cascade slice uncheck when task_done_missing_summary unchecks tasks (#1850) (#1858)
When tasks are [x] done but no T##-SUMMARY.md exists, doctor unchecks
the tasks but left the slice [x] done in the roadmap. The state machine
skips done slices, so unchecked tasks never re-execute and doctor fires
again on every start — infinite loop.

After unchecking tasks via task_done_missing_summary, also uncheck the
slice in the roadmap so the state machine re-enters the executing phase.

Fixes #1850

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:22:23 -06:00
Tom Boucher
1ad1b5d061 fix: defend exit path against ESM module cache mismatch (#1854)
* fix: defend exit path against ESM module cache mismatch (#1839)

Wrap the stopAuto import/call in exit-command.ts with try/catch so
that a mid-session gsd-pi update (which causes stale ESM cache for
native-git-bridge.js exports) does not crash the /exit handler.
A warning is emitted instead. The user's work is already saved;
this path is cleanup only.

Fixes #1839

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use "warning" not "warn" for notify severity type

TS2345: "warn" is not in the severity union type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: update test assertion to match "warning" severity

The source was corrected to "warning" (valid union type), test must match.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 15:22:13 -06:00
Andrew
3f8d7921ca feat: add --host, --port, --allowed-origins flags for web mode (#1847) (#1873)
Wire CLI flags through parseCliArgs → runWebCliBranch → launchWebMode
so users can bind to a custom host/port and whitelist CORS origins for
LAN/Tailscale access.

- Add webHost, webPort, webAllowedOrigins to CliFlags
- Parse --host, --port (validated 1-65535), --allowed-origins (csv)
- Forward into launchWebMode options
- Set GSD_WEB_ALLOWED_ORIGINS in subprocess env when provided
- Add allowedOrigins to WebModeLaunchOptions

Usage: gsd --web --host 0.0.0.0 --port 8080 --allowed-origins http://192.168.1.10:8080

Closes #1847
2026-03-21 15:22:01 -06:00
TÂCHES
8bed02c077 fix: escape parentheses in paths before bash shell-out, fix __extensionDir fallback (#1872)
Closes #1437
2026-03-21 15:14:40 -06:00
TÂCHES
77b220e9e5 fix: use PowerShell Start-Process for Windows browser launch, prevent URL wrapping (#1870)
Closes #1574
2026-03-21 15:12:24 -06:00
TÂCHES
0188b8eaa8 fix: clear stale unit state and restore CWD when step-wizard exits auto-loop (#1869)
Closes #1698
2026-03-21 15:12:16 -06:00
TÂCHES
05a535598d fix: prevent cross-project state leak in brand-new directories (#1639) (#1861)
When GSD is launched in a new empty directory that happens to be inside
an existing git repo (e.g. mkdir ~/Projects/newproject where ~/Projects
has a .git), repoIdentity() resolves to the parent repo's hash and
loads milestones from an unrelated project.

Add isInheritedRepo() to detect when basePath inherits a parent repo's
git root without having its own .gsd. When detected, git init creates
an independent repo so the directory gets a unique identity hash.
Legitimate subdirectory access (cd src/ inside an existing GSD project)
is preserved — the check only triggers when the parent repo has no .gsd.

Closes #1639

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 14:58:25 -06:00
Tom Boucher
7054e5dde6 fix: reconcile worktree HEAD with milestone branch ref before squash merge (#1846) (#1859)
When the worktree HEAD detaches and advances past the named milestone
branch, the branch ref becomes stale. The squash merge only captured
the stale ref, silently orphaning all commits between the branch ref
and the actual worktree HEAD.

Before the squash merge, compare the milestone branch ref with the
worktree's actual HEAD. If the branch ref is an ancestor of the
worktree HEAD, fast-forward the branch ref. If they have diverged,
throw a clear error instead of silently losing commits.

Guarded by worktreeCwd !== originalBasePath_ so non-worktree merge
paths (e.g. parallel-merge) are unaffected.

Fixes #1846
2026-03-21 14:58:16 -06:00
TÂCHES
e5ae9fd249 fix: normalize Windows backslash paths in bash command strings (#1436) (#1863)
On Windows, paths embedded in bash command strings have backslashes
stripped by the shell (e.g. C:\Users\user becomes C:Useruser), causing
cd and other commands to fail silently. This left ~1.4 GB orphaned
worktree directories after milestone completion.

- Normalize all paths to forward slashes before embedding in the
  subagent cmux bash script (cd, tee, process args)
- Add post-teardown orphan detection: warn and attempt rmSync fallback
  if the worktree directory persists after removeWorktree
- Add regression tests for Windows path normalization

Closes #1436

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 14:57:58 -06:00
TÂCHES
333c769e21 fix: parsePlan and verifyExpectedArtifact recognize heading-style task entries (#1691) (#1857)
Closes #1691
2026-03-21 14:53:30 -06:00
TÂCHES
a0031d321e fix: sync all milestone dirs regardless of naming convention (#1547) (#1845)
Remove hardcoded /^M\d{3}/ regex filter from syncGsdStateToWorktree and
syncWorktreeStateBack so milestone directories with non-standard names
(e.g. sprint-alpha, M001-abc123) are synced between main and worktree.

Closes #1547

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 14:47:57 -06:00
Tom Boucher
9fe82c18dc docs: add v2.41.0 release notes to README and docs (#1840)
Update README "What's New" section with v2.41.0 highlights organized by
category: new features (web interface, doctor lifecycle), data loss
prevention (7 critical fixes), auto-mode stability, roadmap parser
improvements, state/git fixes, Windows/platform support, and DX.

- Add web-interface.md documenting the new browser-based UI
- Add web interface entry to docs/README.md index
- Move v2.39-v2.40 highlights to "Previous highlights" section

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:55:28 -06:00
github-actions[bot]
3aaf6951fc release: v2.41.0 2026-03-21 19:45:20 +00:00
Lex Christopherson
626ad25edc fix: skip web build on Windows — Next.js webpack hits EPERM on system dirs
The Windows CI runner's Application Data directory triggers EPERM
when webpack scans it. The web build is a Linux/macOS deployment
target and doesn't need to run on Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:30:23 -06:00
Lex Christopherson
1031400ec3 fix: include web build in main build command
The validate-pack step requires dist/web/standalone/server.js but
the build command didn't produce it. Add build-web-if-stale.cjs to
the build chain — it skips when up-to-date and rebuilds when needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:25:01 -06:00
Tom Boucher
897237ab0a fix: fall through to prose slice parser when checkbox parser yields empty under ## Slices (#1744)
When the ## Slices section exists but contains H3 prose headers instead of
checkboxes, parseRoadmapSlices returned an empty array because the prose
fallback was only invoked when the ## Slices heading was entirely absent.
Now, when the checkbox parser finds zero slices, it falls through to
parseProseSliceHeaders as a second-chance fallback.

Also adds a missing_slice_dir diagnostic in doctor.ts when resolveSlicePath
returns null, with auto-fix via mkdir.

Fixes #1711

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:24:05 -06:00
Tom Boucher
a7ad0caf9f fix(auto): verify merge anchored before worktree teardown (#1829)
* fix(auto): verify merge anchored before worktree teardown

Fixes #1792

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: replace unconditional empty-commit throw with anchor check

Step 10's unconditional throw on nothingToCommit conflicted with step
8b's smarter anchor check (#1792). Step 8b correctly distinguishes
"genuinely safe empty" (code already on main) from "data loss risk"
(unanchored code changes). Updated tests accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:23:50 -06:00
Tom Boucher
77d88407ab fix(auto): reject execute-task with zero tool calls as hallucinated (#1838)
* fix(auto): reject execute-task with zero tool calls as hallucinated

Adds two safeguards against agents that complete with exit 0 but make
no tool calls, producing hallucinated summaries:

1. Zero tool-call guard: after closeoutUnit snapshots metrics for an
   execute-task, check the ledger for toolCalls === 0. If zero, log a
   warning and skip adding the unit to completedUnits so the task is
   retried on the next loop iteration instead of silently advancing.

2. Worktree health check: before dispatching an execute-task, verify
   the basePath has a .git marker and at least one of package.json or
   src/. A broken worktree causes agents to hallucinate since they
   cannot read or write files. Stops auto-mode immediately on failure.

Fixes #1833

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: replace findLast with reverse().find() for ES2022 compat

findLast requires ES2023 lib target. The project uses ES2022.
Functionally identical: [...arr].reverse().find() with explicit type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:23:35 -06:00
Iouri Goussev
563a3797c2 test: add missing git-service coverage for 6 untested paths (#1837)
- MergeConflictError constructor fields (conflictedFiles, strategy,
  branch, mainBranch, name, message content, instanceof checks)
- writeIntegrationBranch rejects gsd/quick/* ephemeral branches
- resolveMilestoneIntegrationBranch returns status:missing when no
  metadata file exists
- resolveMilestoneIntegrationBranch returns status:missing when both
  recorded and configured main_branch are absent (full fallback chain)
- buildTaskCommitMessage appends Resolves #N trailer when issueNumber set
- runPreMergeCheck skips gracefully when no package.json found

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 13:23:25 -06:00
Lex Christopherson
958b8e752d fix: also convert --import resolver path to file URL for Windows
The spawnSync --import flag also receives a bare Windows path.
Convert it with pathToFileURL like the script import.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:11:50 -06:00
Lex Christopherson
702f1a578c fix: use pathToFileURL for Windows-safe ESM import in verification-gate test
Bare "file://" + windowsPath produces invalid URLs on Windows
(e.g. file://D:\...). pathToFileURL correctly produces file:///D:/...

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 13:04:05 -06:00
Tom Boucher
e2b85d4e7f fix(gsd): read depends_on from CONTEXT-DRAFT.md when CONTEXT.md is absent (#1743)
When a milestone has only CONTEXT-DRAFT.md (no CONTEXT.md), the depends_on
frontmatter was silently ignored because _deriveStateImpl() only read from
CONTEXT.md. This caused dep-blocked milestones to be incorrectly promoted
to active status. Now all three dependency-reading paths fall back to
CONTEXT-DRAFT.md when CONTEXT.md is absent.

Fixes #1724

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:56:52 -06:00
Tom Boucher
ab2eab01d2 fix(roadmap): detect ✓ completion marker in prose slice headers (#1816)
parseProseSliceHeaders() always set done:false regardless of ✓ or
(Complete) markers in the title, causing auto-mode to repeatedly
dispatch complete-slice for already-finished slices.

- Detect ✓ prefix before slice ID ("## ✓ S01: Title")
- Detect ✓ after separator ("## S01: ✓ Title")
- Detect (Complete) suffix ("## S01: Title (Complete)")
- Strip markers from title so downstream consumers get clean names
- Add prose format support to markSliceDoneInRoadmap

Fixes #1803

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:55:34 -06:00
Tom Boucher
72f39b6e23 fix(auto): reverse-sync root-level .gsd files on worktree teardown (#1831)
Add QUEUE.md and completed-units.json to the durable file whitelist in
both syncGsdStateToWorktree (forward sync) and syncWorktreeStateBack
(reverse sync). These files are written during milestone closeout but
were not being copied back to the project root, causing state loss on
worktree teardown.

Adds regression test verifying both files survive reverse sync.

Fixes #1787

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:55:25 -06:00
Tom Boucher
f29d54b7e0 fix(tui): prevent freeze when using @ file finder (#1832)
The @ file autocomplete triggered a synchronous native fuzzyFind call
that walks the entire directory tree. On large repos this blocked the
Node.js event loop and froze the TUI.

Three changes fix this:

1. Skip the fuzzy search when the query is empty (bare "@" with nothing
   typed yet) — there is no point walking the full tree with no query.

2. Debounce the initial "@" keystroke instead of firing the search
   synchronously, so rapid typing cancels pending walks and the search
   only runs once the user pauses.

3. Deduplicate consecutive lookups using lastAutocompleteLookupPrefix
   (previously declared but unused) to avoid redundant synchronous
   searches when the prefix hasn't changed.

Fixes #1824

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:55:12 -06:00
Tom Boucher
2f0c078cc2 fix: prevent silent data loss when milestone merge fails due to dirty working tree (#1752)
Three bugs caused mergeMilestoneToMain to silently lose all milestone branch
commits when git merge --squash was rejected by dirty/untracked .gsd/ files:

1. nativeMergeSquash catch block returned success:true when git rejected a
   merge pre-staging ("local changes would be overwritten") because the
   --diff-filter=U conflict check found no markers. Now detects dirty tree
   rejections via stderr and returns a __dirty_working_tree__ sentinel.

2. mergeMilestoneToMain deleted the milestone branch unconditionally even
   when nothingToCommit was true (empty squash). Now throws with a clear
   error and preserves the branch to prevent data loss.

3. clearProjectRootStateFiles only removed STATE.md, auto.lock, and
   META.json but left synced milestone dirs and runtime/units from
   syncStateToProjectRoot. These untracked files blocked squash merges.
   Now cleans all untracked files in synced .gsd/ directories before merge.

Fixes #1738

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:50:58 -06:00