Commit graph

798 commits

Author SHA1 Message Date
Colin Johnson
5fec6ea81e enhance: bring Slack remote questions to parity (#628)
* enhance: bring Slack remote questions to parity

* chore(M004): record integration branch

* fix: restore remote questions adapter import
2026-03-16 09:01:41 -06:00
Jeremy McSpadden
2fd4a1da60 refactor: replace serial prefs wizard with categorized menu (#623)
* refactor: replace serial prefs wizard with categorized menu

The /gsd prefs wizard previously dumped 20+ prompts in sequence, which
was overwhelming. This refactors it into a category picker loop where
users select from 7 categories (Models, Timeouts, Git, Skills, Budget,
Notifications, Advanced), configure only what they need, and return to
the menu with updated summaries showing current values at a glance.

- Extract 7 category functions from monolithic handlePrefsWizard
- Add buildCategorySummaries() for current-value display in menu
- Category loop with Save & Exit / Escape to serialize and write
- No logic changes to individual prompts — pure structural refactor

* fix: narrow ctx.ui.select return type for TypeScript strict mode

ctx.ui.select returns string | string[], so startsWith is not available
without narrowing. Extract to string with typeof guard before dispatching.
2026-03-16 09:01:27 -06:00
Tom Boucher
369bd8aeb9 fix: auto mode re-derives state after discussion fallthrough (#609) (#629)
When /gsd auto is called with no milestone, it delegates to the
discussion flow (showSmartEntry). Previously, if the LLM didn't follow
the discussion protocol — e.g. for simple tasks where it judged the
ceremony overkill and started editing directly — auto mode never
activated. The function returned after showSmartEntry with no retry
or notification, leaving the user in a loop.

Fix: After showSmartEntry returns in both the no-milestone and
pre-planning paths, re-derive state from disk. If the LLM produced
enough artifacts (CONTEXT.md, ROADMAP.md, or advanced the phase),
auto mode proceeds instead of returning. If not, a clear warning
tells the user what happened and what to do next.

This handles the case where the LLM writes files but doesn't follow
the exact discussion → CONTEXT.md → checkAutoStartAfterDiscuss flow.
2026-03-16 09:01:14 -06:00
Tom Boucher
330e5200bc docs: add v2.18/v2.19 feature documentation (#631)
New docs:
- dynamic-model-routing.md — complexity classification, tier models,
  escalation, budget pressure, cost table, adaptive learning
- captures-triage.md — fire-and-forget capture, triage pipeline,
  classification types, dashboard integration, worktree awareness
- visualizer.md — four-tab TUI overlay (progress, deps, metrics,
  timeline), controls, auto-refresh, auto_visualize preference

Updated docs:
- README.md — added links to three new docs
- commands.md — added capture, triage, visualize, knowledge, queue reorder
- configuration.md — added dynamic_routing and auto_visualize settings,
  updated full example with new config options
- auto-mode.md — added capture, visualize sections, dashboard badge,
  dynamic model routing reference
- architecture.md — updated dispatch pipeline (routing + captures steps),
  added key modules table for v2.19
- cost-management.md — added dynamic routing and visualizer tips
2026-03-16 09:00:58 -06:00
Juan Francisco Lebrero
370897df81 feat: add /gsd help command with categorized reference for all subcommands (#630)
Adds /gsd help (aliases: h, ?) that displays a grouped reference of
every available subcommand with usage, flags, and shortcuts.

Commands are organized by category: Workflow, Visibility, Course
Correction, Project Knowledge, Configuration, and Maintenance.

Also simplifies the "Unknown command" error to point users to /gsd help
instead of listing all commands inline.
2026-03-16 08:41:08 -06:00
Lex Christopherson
da1a77d723 2.19.0 2026-03-16 08:33:07 -06:00
Lex Christopherson
0f106b9a06 docs: update changelog for v2.19.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 08:32:54 -06:00
Flux Labs
5ade4bf3ed feat: add workflow visualizer TUI overlay with 4-tab interactive view (#626)
Add `/gsd visualize` command that opens a full-screen TUI overlay with
four tabs: Progress (milestone/slice/task tree), Dependencies (ASCII
dep graph), Metrics (cost/token bar charts), and Timeline (chronological
execution history). Supports Tab/1-4 switching, per-tab scrolling, and
auto-refresh every 2s. Opt-in auto-trigger hint after milestone
completion via `auto_visualize` preference.

New files:
- visualizer-data.ts: async data loader aggregating state + metrics
- visualizer-views.ts: 4 pure view renderers
- visualizer-overlay.ts: overlay class with tab/scroll/cache management
- tests/visualizer-views.test.ts: 21 assertions on view renderers
- tests/visualizer-data.test.ts: 33 source contract assertions

Modified:
- commands.ts: register "visualize" subcommand + handler
- auto.ts: milestone completion hint when auto_visualize enabled
- preferences.ts: add auto_visualize preference key
2026-03-16 08:19:08 -06:00
Juan Francisco Lebrero
88bdf9bc8d fix: use absolute paths for write-target variables in auto-mode prompts (#627)
In worktree contexts, the LLM received relative output paths like
`.gsd/milestones/M002/slices/S01/S01-RESEARCH.md` combined with a
working directory containing `.gsd/worktrees/M002`. The double .gsd
in the resulting path confused the LLM, which resolved the relative
path against the project root instead of the worktree — writing
artifacts to the wrong location and triggering loop detection.

All write-target path variables (outputPath, taskSummaryPath,
sliceSummaryPath, milestoneSummaryPath, replanPath, planPath,
uatResultPath, assessmentPath, secretsOutputPath) are now passed
as absolute paths via join(base, relPath), eliminating the need
for the LLM to do path arithmetic in confusing worktree layouts.
2026-03-16 08:18:53 -06:00
Tom Boucher
e0a309f5b5 feat(M004): mid-execution flexibility — capture, triage, and redirect (#512)
Solo developers can fire-and-forget thoughts during auto-mode execution
via /gsd capture. The system triages accumulated captures at natural seams
between tasks, classifies their impact into five types (quick-task, inject,
defer, replan, note), and proposes appropriate action with user confirmation
for plan-modifying resolutions.

Pipeline: capture → triage → confirm → resolve → resume
- /gsd capture appends to .gsd/CAPTURES.md (worktree-aware)
- Triage fires automatically between tasks in handleAgentEnd
- Five resolution types: inline quick task, inject task into plan,
  defer for reassess, trigger replan with context, acknowledge as note
- Dashboard overlay shows pending capture count badge
- Capture context injected into replan-slice and reassess-roadmap prompts
- Parse failure falls back to note — pipeline never blocks

New modules: captures.ts, triage-ui.ts, triage-resolution.ts
New prompt: triage-captures.md
52 tests across 3 test files, all passing
Requirements R045-R051 validated

Closes #505

chore: pre-merge cleanup — remove dead code, single-read dashboard optimization

- Remove processTriageResults() and associated types (dead code, superseded by
  inline resolution in auto.ts dispatch loop)
- Add countPendingCaptures() for single-read regex count on dashboard hot path
  (replaces two-phase hasPendingCaptures + loadPendingCaptures)
- Update triage-dispatch tests to match new implementation
2026-03-16 07:54:12 -06:00
Flux Labs
77309207ce feat: dynamic model routing for token consumption optimization (#579)
* feat: dynamic model routing for token consumption optimization (#575)

Add complexity-based model routing that classifies units into light/standard/heavy
tiers and routes to cheaper models when appropriate. Reduces token consumption
by 20-50% for users on capped plans.

- Complexity classifier with heuristic-based tier assignment (no LLM call)
- Model router with downgrade-only semantics (user's config is ceiling)
- Budget-pressure-aware routing (more aggressive as budget fills)
- Cross-provider cost comparison via bundled cost table
- Hook classification support
- Escalation on failure (light → standard → heavy)
- Full preference validation and merge support
- Metrics tracking with tier and downgrade fields
- 40 new tests (classifier, router, cost table)

Closes #575

* feat: phases 2-4 — dashboard, adaptive learning, task introspection

Phase 2 — Observability & Dashboard:
- Tier badge [L]/[S]/[H] displayed in progress widget next to phase label
- Dynamic routing savings summary shown in footer when units have been downgraded
- Tier and modelDowngraded fields passed through snapshotUnitMetrics

Phase 3 — Adaptive Learning:
- New routing-history.ts: tracks success/failure per tier per unit-type pattern
- Rolling window of 50 entries per pattern to prevent stale data
- User feedback support (over/under/ok) with 2x weight vs automatic
- Failure rate >20% auto-bumps tier for that pattern
- Tag-specific patterns (e.g. execute-task:docs) for granular learning
- History persists to .gsd/routing-history.json
- Classifier consults adaptive history before finalizing tier

Phase 4 — Task Plan Introspection:
- Code block counting in task plans (5+ blocks → heavy)
- Complexity keyword detection: migration, architecture, security,
  performance, concurrency, compatibility
- Multiple complexity keywords (2+) → heavy, single → standard
- New codeBlockCount and complexityKeywords fields in TaskMetadata

Tests: 16 new tests (routing history + introspection), 419 total passing
2026-03-16 07:53:53 -06:00
Adam Dry
7567d2db05 test: add feature-branch lifecycle integration test (#624)
* test: add feature-branch lifecycle integration test

Proves the core invariant: milestone worktrees branch from and merge
back to the feature branch, never touching main. Covers:
- Full lifecycle with unique milestone IDs (M001-xxxxxx format)
- Untracked .gsd/ planning files copied into worktree
- Multiple successive milestones on the same feature branch
- Main branch completely untouched throughout

* fix: commitCount return type (parseInt)
2026-03-16 07:52:43 -06:00
Flux Labs
c8f8795e73 fix: handle worktree lifecycle on mid-session milestone transitions (#616) (#618) 2026-03-16 07:38:29 -06:00
Juan Francisco Lebrero
9ffb927856 fix: eager template cache warming prevents version-skew crash in long auto-mode sessions (#621) 2026-03-16 07:38:00 -06:00
Tom Boucher
d065964c4a enhance: Discord integration parity with Slack + documentation (#620) 2026-03-16 07:37:28 -06:00
Lex Christopherson
95849c46fd 2.18.0 2026-03-16 07:18:55 -06:00
Lex Christopherson
6eddc6d5a2 docs: update changelog for v2.18.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 07:18:32 -06:00
Flux Labs
6998ef2ae4 docs: comprehensive update to preferences reference and configuration guide (#614)
Update both docs/configuration.md (user-facing) and
src/resources/extensions/gsd/docs/preferences-reference.md (internal)
with complete coverage of all GSD preferences:

- Add /gsd prefs subcommands table (global, project, status, wizard, setup)
- Document token_profile (budget/balanced/quality) and phases settings
- Document context_pause_threshold field
- Document remote_questions configuration (Slack/Discord)
- Document git.merge_strategy (squash/merge) and git.isolation (worktree/branch)
- Expand post_unit_hooks with missing agent field
- Expand pre_dispatch_hooks with skip_if, unit_type, model fields
  and action validation rules
- Add known unit types list for hook before/after arrays
- Add examples for pre-dispatch hooks (modify/skip/replace)
- Add examples for token profile, phases, and remote questions
- Update models to show all 6 phases (research, planning, execution,
  execution_simple, completion, subagent)
- Add full example combining all major settings
2026-03-16 07:09:50 -06:00
Tom Boucher
2924a1d666 fix: showNextAction falls back to select() when custom() returns undefined (#447) (#615)
In RPC mode, ctx.ui.custom() returns undefined without emitting any event.
This caused showNextAction() — and all 13+ call sites in guided-flow.ts —
to silently complete without taking action. No error thrown, no event
emitted, command handler returns normally.

Fix: After custom() returns, check for undefined/null and fall back to
ctx.ui.select() which IS implemented in RPC mode. Maps the action list
to select labels and resolves the chosen action id.
2026-03-16 07:09:37 -06:00
Lex Christopherson
f184880db6 chore: sync package-lock.json version to 2.17.0 2026-03-16 06:59:58 -06:00
Tom Boucher
15be720fbf fix: multiple open issue bugfixes (#592, #603, #606, #608, #602) (#612)
Four bugfixes for open issues:

1. Worktree created from integration branch, not main (#606)
   - createAutoWorktree reads integration branch from META.json
   - mergeMilestoneToMain merges to integration branch, not hardcoded main
   - createWorktree accepts optional startPoint parameter

2. Resolve project root from worktree paths in all commands (#608, #602)
   - Add resolveProjectRoot() to detect .gsd/worktrees/ in cwd
   - All GSD commands use projectRoot() instead of raw process.cwd()
   - Fixes stale cwd after milestone completion (#608)
   - Fixes discuss/status basepath disagreement (#602)

3. Milestone merge skipped in branch isolation mode (#603)
   - Add branch-mode fallback when isInAutoWorktree() is false
   - Detects milestone/* branch and performs squash-merge
   - Uses same mergeMilestoneToMain flow as worktree mode

4. Remote questions onboarding missing .js module (#592)
   - Extract saveRemoteQuestionsConfig into compiled src/ helper
   - Avoids cross-boundary import from compiled JS to raw .ts
2026-03-16 06:58:23 -06:00
Flux Labs
7e25e6d427 fix: prevent stale worktree cwd after milestone completion (#608) (#610)
After milestone completion and merge, the process cwd could remain
inside .gsd/worktrees/<MID>/, causing new milestone writes to land
in the wrong directory.

Three-layer fix:
1. escapeStaleWorktree() at startAuto entry — detects if base path
   is inside .gsd/worktrees/ and chdir back to project root
2. stopAuto() unconditionally restores cwd to originalBasePath,
   not just when isInAutoWorktree returns true (module state may
   have been cleared by mergeMilestoneToMain already)
3. Milestone merge error handler restores cwd on partial failure
   where mergeMilestoneToMain chdir'd but then threw

Closes #608
2026-03-16 06:58:02 -06:00
Flux Labs
b0f880689b fix: prevent heap OOM during long-running auto-mode sessions (#611) (#613)
Multiple sources of unbounded memory growth caused V8 to OOM after
~50 minutes of auto-mode operation:

1. activity-log.ts: saveActivityLog serialized ALL session entries
   into a single string for SHA1 dedup, allocating hundreds of MB
   per unit cycle. Now uses streaming writes (writeSync per entry)
   and a lightweight fingerprint (entry count + last 3 entries hash)
   instead of full-content hashing.

2. activity-log.ts: activityLogState Map was never cleared between
   sessions, accumulating lastSnapshotKeyByUnit entries indefinitely.
   Added clearActivityLogState() export, called from stopAuto().

3. auto.ts: completedUnits array grew unbounded for dashboard
   display. Now capped at 200 entries and cleared on stopAuto().

4. paths.ts: dirEntryCache and dirListCache Maps grew without bounds
   between clearPathCache() calls. Added DIR_CACHE_MAX (200) eviction
   — when cache exceeds limit, it's cleared before adding new entries.

Closes #611
2026-03-16 06:57:39 -06:00
Tom Boucher
27cfababdb fix: worktree created from integration branch, not main (#606) (#607) 2026-03-16 06:35:28 -06:00
Flux Labs
7e0cdec672 feat: expand preferences wizard with all missing configurable fields (#580) 2026-03-16 06:23:47 -06:00
Flux Labs
9ed812ed54 feat: dynamic model discovery & provider management UX (#581) 2026-03-16 06:23:18 -06:00
Copilot
570f6195be Keep /gsd auto artifact writes scoped to the active milestone worktree (#590) 2026-03-16 06:22:59 -06:00
Tom Boucher
2ae4633d05 docs: add comprehensive documentation set and update README (#605) 2026-03-16 06:21:43 -06:00
Flux Labs
a9b14dc181 feat: add .gsd/KNOWLEDGE.md — persistent project-specific context (#585) 2026-03-16 06:15:18 -06:00
deseltrus
e5244658b3 fix(auto): tool-aware idle detection prevents false interruption of long-running tasks (#596) 2026-03-16 06:07:14 -06:00
deseltrus
ce553ec022 fix: parseContextDependsOn() destroys unique milestone ID case, breaking dependency resolution (#604) 2026-03-16 06:06:09 -06:00
deseltrus
0820b1196d feat: queue reorder — reorder milestone execution via /gsd queue (#460) 2026-03-16 06:05:45 -06:00
Lex Christopherson
1d1b91f428 2.17.0 2026-03-15 22:26:55 -06:00
Lex Christopherson
39a524614a docs: update changelog for v2.17.0 2026-03-15 22:26:41 -06:00
Flux Labs
d35ae683f1 Fix #453 native hangs in GSD auto-mode paths (#502)
* fix: avoid native hangs in gsd auto paths

* fix: use .js extension in edit-diff.test.ts import for tsc compatibility

* fix: prevent OOM on large file diffs and implement context-line windowing

- Add size guard (MAX_DP_CELLS=4M) to buildLineDiff that falls back to a
  linear-time prefix/suffix matching algorithm for large files, preventing
  the O(n*m) DP table from causing OOM crashes
- Implement contextLines parameter in generateDiffString so only lines
  within N lines of a change are rendered (with "..." separators), matching
  unified diff behavior — the parameter was previously accepted but ignored
- Add tests for both context windowing and large-file fallback

---------

Co-authored-by: TÂCHES <afromanguy@me.com>
2026-03-15 22:22:58 -06:00
Andriyansyah Nurrachman
132ae92944 feat: update ollama cloud provider models (#578) 2026-03-15 22:22:29 -06:00
Mannan Kant
96f5b58bd3 fix(pi-ai): address review comments on #504 — exhaustive switch, tests, cleanup (#587)
- Restore exhaustive never check in mapStopReason (throw on unhandled FinishReason)
- Add 12 unit tests for sanitizeSchemaForGoogle covering patternProperties removal,
  const→enum conversion at various depths, arrays, deeply nested objects, pass-through
- Simplify redundant recursion branches into single typeof object catch-all
- Fix misleading comment ("only in anyOf/oneOf") — conversion happens everywhere
- Drop unnecessary (p: Part) annotation; TypeScript infers it from @google/genai types

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-15 22:21:20 -06:00
Tom Boucher
67341caef1 feat: token optimization — profile presets, context compression, complexity routing, budget prediction (#582)
Reduces auto-mode token consumption by 40-60% through coordinated
optimizations driven by a single token_profile preference.

Profile presets (budget/balanced/quality):
- One preference key coordinates model selection, phase skipping,
  context compression, and subagent routing
- Balanced is the default for new projects (D046)
- Explicit user preferences always override profile defaults

Phase skipping:
- Guard clauses on research-milestone, research-slice, and
  reassess-roadmap dispatch rules
- Skipped phases return null (fall-through), preserving state machine
- Budget profile skips all research + reassess; balanced skips slice
  research only

Context compression:
- inlineLevel parameter (full/standard/minimal) on 6 prompt builders
- Minimal: only output template + essential context (≥30% reduction)
- Standard: skip redundant templates
- Full: current behavior unchanged

Complexity routing:
- classifyTaskComplexity() for task plans (step/file/signal heuristics)
- classifyUnitComplexity() for unit types with budget pressure
  thresholds at 50/75/90% (from #579)
- execution_simple model config for cheap simple-task routing
- escalateTier() for failure recovery (light→standard→heavy)

Adaptive learning (from #579):
- routing-history.ts tracks success/failure per tier per pattern
- Rolling 50-entry window, 20% failure threshold auto-bumps tier
- User feedback weighted 2x vs automatic detection
- Persists to .gsd/routing-history.json

Budget prediction:
- getAverageCostPerUnitType() + predictRemainingCost() in metrics
- projectedRemainingCost + profileDowngraded in AutoDashboardData
- One-way auto-downgrade within a milestone (D048)

Addresses #575

95 tests across 5 test files, all passing.
2026-03-15 22:20:38 -06:00
Flux Labs
4c283192bd fix: allow stopping auto-mode from a different terminal (#586)
* fix: allow stopping auto-mode from a different terminal (#584)

Auto-mode lock file was written to the worktree path instead of the
project root, making it invisible to other processes. Additionally,
/gsd stop only checked in-memory state which is process-local.

- Add lockBase() helper to always write auto.lock at project root
- Add stopAutoRemote() for cross-process stop via SIGTERM
- Update /gsd stop to fall back to lock-file-based remote stop

* fix: handle Windows SIGTERM behavior in stop-auto-remote test

On Windows, SIGTERM is not interceptable by Node.js processes — the
process exits with code 1 rather than running the SIGTERM handler.
Accept either exit code on Windows while still asserting clean exit (0)
on Unix platforms.
2026-03-15 22:19:04 -06:00
Flux Labs
5866bb0b27 fix: parse cache collision causing false loop detection on complete-slice (#583)
cacheKey() used length + first/last 100 chars, which collides when a
checkbox changes [ ] → [x] mid-file (same length, same endpoints).
verifyExpectedArtifact() only cleared the path cache, not the parse
cache, so parseRoadmap() returned stale data with done=false.

- Add clearParseCache() to verifyExpectedArtifact alongside clearPathCache
- Include middle 100-char sample in cacheKey to prevent interior collisions
- Add regression test for the cache collision scenario
2026-03-15 22:10:48 -06:00
Flux Labs
5a662c4655 feat: add git.commit_docs setting to keep .gsd/ local-only (#588)
* feat: add git.commit_docs setting to keep .gsd/ local-only (#501)

Adds a new `commit_docs` boolean to git preferences. When set to `false`:
- The entire `.gsd/` directory is added to `.gitignore`
- `smartStage()` excludes all `.gsd/` files from commits
- Bootstrap init skips the "chore: init gsd" commit
- `writeIntegrationBranch()` skips committing metadata
- The self-heal that removes blanket `.gsd/` patterns is bypassed

This allows users in corporate environments or mixed teams to use GSD
without polluting the shared git repository with planning artifacts.

Closes #501

* feat: add commit_docs toggle to preferences wizard

Adds "Track .gsd/ planning docs in git" to the /gsd prefs wizard,
allowing users to toggle commit_docs interactively alongside other
git settings like main_branch.
2026-03-15 22:09:29 -06:00
Lex Christopherson
acb598c4b8 2.16.0 2026-03-15 20:29:48 -06:00
Lex Christopherson
51bb27c334 docs: update changelog for v2.16.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 20:29:34 -06:00
Lex Christopherson
f1401bb7f6 docs: add /gsd steer to commands table
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 20:28:32 -06:00
Lex Christopherson
c9c110fa8d fix: auto-mode continues after guided milestone planning
The guided flow's "Create roadmap" path never set pendingAutoStart,
so checkAutoStartAfterDiscuss() always returned false after planning
completed. Auto-mode stalled at "Milestone planned" instead of
proceeding to slice research/execution.

Three fixes:
- Set pendingAutoStart when choice === "plan" in showSmartEntry
- Relax Gate 1 to accept ROADMAP.md (plan path) or CONTEXT.md (discuss path)
- Add STATE.md write instruction to guided-plan-milestone prompt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 20:28:32 -06:00
Lex Christopherson
f0c1a89146 chore(M004): record integration branch 2026-03-15 20:28:32 -06:00
Lex Christopherson
3a90165f38 docs(M004): context, requirements, and roadmap 2026-03-15 20:28:32 -06:00
Flux Labs
c8b42ed2ae feat: native perf optimizations — deriveState, JSONL, paths, parsing (#576)
Four native Rust optimizations to eliminate hot-path bottlenecks:

1. deriveState raw content (gsd_parser.rs, state.ts):
   - Added rawContent field to ParsedGsdFile in batch parser
   - Eliminates 43-line frontmatter re-serialization loop in state.ts
   - Batch cache now stores original file content directly

2. JSONL streaming parser (gsd_parser.rs, session-forensics.ts):
   - Added parseJsonlTail() — reads from file tail with constant memory
   - Handles arbitrary file sizes (no more 10MB OOM risk)
   - synthesizeCrashRecovery and readLastActivityLog use native first

3. Native directory tree index (gsd_parser.rs, paths.ts):
   - Added scanGsdTree() — walks .gsd/ tree once, returns all entries
   - paths.ts builds lookup map from native scan
   - cachedReaddirWithTypes/cachedReaddir check native cache first
   - Eliminates 20-50 readdirSync calls per dispatch

4. Native plan/summary parsers (gsd_parser.rs, files.ts):
   - Added parsePlanFile() — parses tasks, must-haves, estimates
   - Added parseSummaryFile() — parses frontmatter, sections, files
   - files.ts calls native first, falls back to JS regex parsers
   - 3-5x faster per file, ~20 files per deriveState

All optimizations follow the established pattern: native-first with
JS fallback when native module unavailable.
2026-03-15 20:16:42 -06:00
Flux Labs
343a43f028 feat: move git operations to Rust via git2 crate (#572)
* feat: move git operations to Rust via git2 crate (#524)

Eliminates ~70 execSync/execFileSync git CLI calls across 15 TypeScript
files by implementing native libgit2 operations in Rust and routing all
consumers through the native-git-bridge.

Rust (native/crates/engine/src/git.rs):
- Added 28 new NAPI functions covering both read and write operations
- Read: git_is_repo, git_has_staged_changes, git_diff_stat,
  git_diff_name_status, git_diff_numstat, git_diff_content,
  git_log_oneline, git_worktree_list, git_branch_list,
  git_branch_list_merged, git_ls_files, git_for_each_ref,
  git_conflict_files, git_batch_info
- Write: git_init, git_add_all, git_add_paths, git_reset_paths,
  git_commit, git_checkout_branch, git_checkout_theirs,
  git_merge_squash, git_merge_abort, git_rebase_abort,
  git_reset_hard, git_branch_delete, git_branch_force_reset,
  git_rm_cached, git_rm_force, git_worktree_add,
  git_worktree_remove, git_worktree_prune, git_revert_commit,
  git_revert_abort, git_update_ref

TypeScript (native-git-bridge.ts):
- Added 35 bridge functions with native-first + execSync fallback
- New types: GitDiffStat, GitNameStatus, GitNumstat, GitLogEntry,
  GitWorktreeEntry, GitBatchInfo, GitMergeResult

Consumer migrations (15 files):
- worktree-manager.ts: removed local runGit/getMainBranch, all ops native
- auto-worktree.ts: merge, checkout, conflict resolution all native
- git-service.ts: smart staging, commits, snapshots all native
- auto.ts, guided-flow.ts: repo init/bootstrap native
- auto-supervisor.ts: working tree detection native
- git-self-heal.ts: merge/rebase abort, reset all native
- doctor.ts: health checks, branch listing, worktree cleanup native
- commands.ts: branch/snapshot cleanup native
- session-forensics.ts: diff stat queries native
- auto-recovery.ts: merge state reconciliation native
- gitignore.ts, undo.ts, worktree-command.ts: remaining ops native

Kept as execSync (by design):
- git push (credential handling too complex for libgit2)
- native-git-bridge.ts fallbacks (graceful degradation)
- runPreMergeCheck (runs arbitrary user commands)

Closes #524

* fix: restore getMainBranch export from worktree-manager

The agent migration removed getMainBranch from worktree-manager.ts but
worktree-command.ts still imports it. Re-add as a thin wrapper around
nativeDetectMainBranch.

* fix: address PR #572 review feedback — security, correctness, error handling

CRITICAL:
- Path traversal protection via validate_path_within_repo() for
  git_rm_force and git_checkout_theirs
- git_branch_delete defaults to safe delete (force=false)

HIGH:
- Replace silent .ok() with proper error propagation in git_commit,
  git_merge_abort, git_rebase_abort, git_rm_force, git_checkout_theirs
- nativeDiffStat fallback parses numeric stats from git output
- nativeBatchInfo fallback counts staged/unstaged from porcelain status

MEDIUM:
- Wire up dead force param in removeWorktree()
- Read MERGE_MSG/SQUASH_MSG when commit message empty
- nativeLsFiles uses gitFileExec without fragile quote wrapping
- Fix operator precedence in git_ls_files
2026-03-15 20:02:10 -06:00
78slogs
6d84d1c317 fix: arrow key cursor not updating + Shift+Enter not inserting newlines (#485)
Fix two editor input bugs:

1. Arrow key cursor movement not visually updating (fixes #464)
   The layout cache key only included {width, textVersion}. Cursor-only
   moves don't change textVersion, so stale cached layout was returned
   and the diff renderer skipped repaint. Added cursorLine and cursorCol
   to the cache key so cursor movements invalidate the cache.

2. Shift+Enter not inserting newlines in non-kitty terminals (Zed, VS Code, etc.)
   The /terminal-setup command configures terminals to send ESC+CR (\x1b\r)
   for Shift+Enter. But the followUp app action (bound to alt+enter) was
   intercepting \x1b\r in CustomEditor.handleInput before the editor's
   newLine handler could see it — because in non-kitty terminals, \x1b\r
   matches alt+enter. Now when kitty protocol is not active and \x1b\r is
   received, the followUp match is skipped so it falls through to newLine.
   Alt+Enter followUp still works in kitty-protocol terminals (iTerm2,
   Ghostty, Kitty, WezTerm) where the key combos are distinguishable.

Co-authored-by: TÂCHES <afromanguy@me.com>
2026-03-15 19:47:49 -06:00