Commit graph

160 commits

Author SHA1 Message Date
github-actions[bot]
290b2b2a25 release: v2.35.0 2026-03-19 22:05:29 +00:00
TÂCHES
efc23a2342 Merge pull request #1498 from gsd-build/fix/lsp-get-server-for-file
fix: restore LSP single-server selector export
2026-03-19 15:53:26 -06:00
TÂCHES
cc17d20820 Merge pull request #1457 from frizynn/refactor/agent-session-model-switching
refactor: consolidate model switching logic in agent-session
2026-03-19 15:52:12 -06:00
TÂCHES
45193d5499 Merge pull request #1458 from frizynn/refactor/resource-loader-generics
refactor: consolidate resource-loader duplicate methods into generics
2026-03-19 15:52:01 -06:00
TÂCHES
b5563e18c6 Merge pull request #1459 from frizynn/refactor/shared-lock-utils
refactor: extract shared file lock utilities
2026-03-19 15:51:47 -06:00
TÂCHES
0259f0f2e3 Merge pull request #1479 from frizynn/refactor/rpc-mode-dedup
refactor: deduplicate RPC mode shared patterns
2026-03-19 15:50:03 -06:00
TÂCHES
0c2105d71d Merge pull request #1484 from frizynn/refactor/agent-session-decomposition
refactor: extract retry handler and compaction orchestrator from agent-session
2026-03-19 15:48:59 -06:00
Lex Christopherson
5e501d59a0 fix: restore lsp single-server selector export 2026-03-19 15:46:20 -06:00
TÂCHES
5ab6fa2853 Merge pull request #1448 from frizynn/refactor/deduplicate-small-utilities
refactor: deduplicate toPosixPath, ZERO_USAGE, and shortenPath utilities
2026-03-19 15:46:13 -06:00
TÂCHES
dea2f1a426 Merge pull request #1449 from frizynn/refactor/compaction-helpers-extraction
refactor: extract shared helpers in compaction module
2026-03-19 15:45:21 -06:00
TÂCHES
cb9bd2bc99 Merge pull request #1447 from frizynn/refactor/extension-runner-emit-consolidation
refactor: consolidate extension runner emit methods into shared invokeHandlers
2026-03-19 15:44:37 -06:00
TÂCHES
671b72b684 Merge pull request #1446 from frizynn/refactor/extension-type-guards-consolidation
refactor: consolidate extension type guards and inline handler aliases
2026-03-19 15:44:17 -06:00
TÂCHES
66bca9c8a2 Merge pull request #1477 from frizynn/refactor/tree-render-shared-utils
refactor: extract shared tree rendering utilities
2026-03-19 15:40:26 -06:00
TÂCHES
e01536c8a3 Merge pull request #1445 from frizynn/refactor/lsp-deduplication
refactor: consolidate duplicate patterns in LSP module
2026-03-19 15:40:07 -06:00
TÂCHES
364bd5b65b Merge pull request #1430 from trek-e/fix/1423-session-cost-compaction
fix: accumulate session cost independently of message array (#1423)
2026-03-19 15:39:19 -06:00
Juan Francisco Lebrero
54b1446fb2 refactor: simplify settings manager with generic setter helpers (#1461)
Replace 30+ repetitive setter method bodies with four generic private
helpers: setGlobalSetting, setScopedSetting, setNestedGlobalSetting,
and setProjectSetting. Each setter method retains its original public
signature and behavior — only the internal implementation is consolidated.

Methods with custom logic (setEditorPaddingX, setAutocompleteMaxVisible,
setSearchExcludeDirs, setFallbackChain, removeFallbackChain,
setDefaultModelAndProvider) are left unchanged or minimally adapted.

Net reduction: 79 lines (164 deleted, 85 added).
2026-03-19 15:37:24 -06:00
Juan Francisco Lebrero
988ef61488 refactor: consolidate theme files and remove manual schema (#1478)
- Delete theme-schema.json (335 lines): redundant with the TypeBox
  schema already defined in theme.ts, only referenced via $schema URLs
  in the JSON files for editor autocomplete.
- Delete dark.json (85 lines) and light.json (84 lines): move built-in
  theme definitions into themes.ts as TypeScript objects, eliminating
  runtime filesystem reads and the getThemesDir() dependency.
- Export ThemeJson type from theme.ts so themes.ts can reference it.
- Net reduction: ~319 lines removed.
2026-03-19 15:35:56 -06:00
Juan Francisco Lebrero
334a7cf076 refactor: extract slash command handlers from interactive-mode (#1485)
Move slash command dispatch logic and 12 individual command handlers
(/export, /share, /copy, /name, /session, /changelog, /hotkeys,
/compact, /thinking, /edit-mode, /arminsayshi, plus showThinkingSelector)
into a new slash-command-handlers.ts module.

InteractiveMode now delegates to dispatchSlashCommand() via a
SlashCommandContext interface, keeping the integration surface minimal.
Handlers that are also invoked from keybindings/events remain on
InteractiveMode and are accessed through the context.

Reduces interactive-mode.ts from 4,783 to 4,272 lines (-511).
2026-03-19 15:34:14 -06:00
Juan Francisco Lebrero
4e29ca4544 refactor: remove dead code (unused exports) (#1486)
Remove exported functions/constants/classes that are never imported
anywhere else in the codebase:

Fully removed (not used anywhere):
- nativeAvailable (native)
- getApiProviders, unregisterApiProviders (pi-ai/api-registry)
- createAssistantMessageEventStream (pi-ai/event-stream)
- getOverflowPatterns (pi-ai/overflow)
- validateToolCall (pi-ai/validation)
- getToolsDir (pi-coding-agent/config)
- emitSessionShutdownEvent (extensions/runner)
- syncContent, notifySaved (lsp/client)
- getServerForFile, hasCapability (lsp/config)
- severityToIcon, formatPosition, formatTextEdit, symbolKindToName (lsp/utils)
- clearApiKeyCache (model-registry)
- restoreModelFromSession (model-resolver)
- isLightTheme (theme)
- loadPhoton + all internal helpers (photon)
- extractAnsiCode (pi-tui/utils)

De-exported (used locally, not externally):
- extractRetryAfterMs, inferCopilotInitiator, extractRetryDelay,
  buildRequest, requiresToolCallId, registerBuiltInApiProviders,
  streamProxy, isBunRuntime, detectInstallMethod, getPackageDir,
  getPackageJsonPath, ansiToHtml, DEFAULT_APP_KEYBINDINGS,
  DEFAULT_KEYBINDINGS, shutdownClient, sendNotification, shutdownAll,
  applyTextEditsToString, wrapWithLspmux, severityToString,
  COMPACTION_SUMMARY_PREFIX/SUFFIX, BRANCH_SUMMARY_PREFIX/SUFFIX,
  bashExecutionToText, defaultModelPerProvider, parseModelPattern,
  parseCommandArgs, substituteArgs, loadEntriesFromFile,
  findMostRecentSession, FileSettingsStorage, InMemorySettingsStorage,
  migrateAuthToAuthJson, migrateSessionsFromAgentRoot,
  parseSearchQuery, matchSession, compareVersions, isWaylandSession,
  getToolPath, wordWrapLine
2026-03-19 15:33:32 -06:00
github-actions[bot]
f196309295 release: v2.34.0 2026-03-19 21:08:44 +00:00
frizynn
3090f968f4 refactor: extract retry handler and compaction orchestrator from agent-session
Extract two self-contained subsystems from agent-session.ts (3,367 -> 2,737 lines):

- RetryHandler: auto-retry with exponential backoff, credential rotation,
  and cross-provider fallback logic
- CompactionOrchestrator: manual/auto compaction, overflow recovery, and
  extension integration for custom compaction providers

Also add shared getErrorMessage() utility to replace repeated
`err instanceof Error ? err.message : String(err)` patterns.

The extracted modules receive AgentSession state via dependency injection
interfaces, avoiding state duplication. AgentSession remains the coordinator
that delegates to these modules.
2026-03-19 16:46:14 -03:00
frizynn
502067c213 refactor: deduplicate RPC mode shared patterns
Extract the duplicated commandContextActions implementations from
rpc-mode.ts and print-mode.ts into a shared
createDefaultCommandContextActions() factory in
modes/shared/command-context-actions.ts.

Both headless modes (RPC and print) had identical implementations of
waitForIdle, newSession, fork, navigateTree, switchSession, and reload
that simply delegate to AgentSession. The shared factory provides these
defaults; interactive mode continues to layer TUI-specific behavior on
top via its own overrides.

Also fixes a subtle redundancy in print mode where newSession manually
called options.setup after session.newSession(), even though
session.newSession() already handles the setup callback internally.
2026-03-19 16:38:51 -03:00
frizynn
6cb8e3c524 refactor: extract shared tree rendering utilities
Extract duplicated tree rendering logic from tree-selector.ts and
session-selector.ts into tree-render-utils.ts:

- computeScrollWindow: centered scroll window calculation
- renderCursor: accent-colored selection cursor indicator
- applyRowHighlight: selected-row background + truncation
- renderScrollPosition: muted (current/total) position indicator
- buildTreePrefix: tree connector prefix from ancestor-continuation flags
- TREE_BRANCH/TREE_LAST/TREE_PIPE/TREE_SPACE connector character constants
2026-03-19 16:37:40 -03:00
frizynn
23d0ea656d refactor: extract shared file lock utilities
Extract the duplicated file lock mechanism from auth-storage.ts and
session-manager.ts into a shared lock-utils.ts module.

- acquireLockSyncWithRetry(): throwing variant (used by auth-storage)
- tryAcquireLockSync(): non-throwing variant (used by session-manager)
- acquireLockAsync(): async lock with retries and staleness detection

Removes ~55 lines of duplicated retry-loop logic. The shared module
also provides a foundation for deduplicating identical patterns in
settings-manager.ts and models-json-writer.ts.
2026-03-19 15:16:56 -03:00
frizynn
a78121b35c refactor: consolidate resource loader with generic update/dedupe methods
- Replace dedupePrompts() and dedupeThemes() with generic dedupeResources<T>()
  that accepts getName/getPath/resourceType callbacks
- Replace discoverSystemPromptFile() and discoverAppendSystemPromptFile() with
  generic discoverFileInSearchPaths(filename)
- Import ResourceCollision type for use in dedupeResources signature
- Net reduction of 24 lines (868 → 844) with elimination of duplicated logic
2026-03-19 15:16:21 -03:00
frizynn
c6c45cb1c0 refactor: consolidate model switching logic in agent-session
Extract the duplicated model-switching sequence (set model, append
session change, persist settings, re-clamp thinking level, emit event)
from setModel(), _cycleScopedModel(), and _cycleAvailableModel() into a
shared _applyModelChange() helper. Removes ~30 lines of repeated code.
2026-03-19 15:16:18 -03:00
frizynn
166243bfe5 refactor: extract shared helpers in compaction module
Move duplicated patterns from compaction.ts and branch-summarization.ts
into shared utilities in utils.ts:

- getMessageFromEntry(): unified entry-to-message conversion with
  optional toolResult skipping for branch summarization
- collectMessages(): replaces three identical for-loops that collect
  AgentMessages from entry ranges
- extractTextContent(): replaces five instances of the
  .filter(text).map(text).join() pattern
- createSummarizationMessage(): replaces three identical user-message
  construction blocks for LLM summarization calls

Net reduction of ~90 lines of duplication.
2026-03-19 14:56:00 -03:00
frizynn
385d936689 refactor: deduplicate toPosixPath, ZERO_USAGE, and shortenPath utilities
- toPosixPath: remove private copies in skills.ts and package-manager.ts,
  import from canonical utils/path-display.ts
- ZERO_USAGE: export from agent-loop.ts, replace inline zero-usage
  objects in agent.ts and proxy.ts
- shortenPath: extract to shared modes/interactive/utils/shorten-path.ts,
  import in tool-execution.ts and session-selector.ts
2026-03-19 14:55:30 -03:00
frizynn
02b42bfffe refactor: consolidate 9 emit methods in extension runner into shared invokeHandlers
Extract the duplicated loop pattern (create context, iterate extensions,
iterate handlers, try/catch, emitError) into a private invokeHandlers()
helper. Each emit method is now a thin wrapper that delegates the
iteration to invokeHandlers and provides only its result-processing
callback. Net reduction of ~124 lines with identical runtime behavior.
2026-03-19 14:55:18 -03:00
frizynn
bbc180a3b6 refactor: consolidate extension type guards and inline handler type aliases
Replace 7 individual ToolResultEvent type guards (isBashToolResult,
isReadToolResult, etc.) with a unified isToolResultEventType() function,
mirroring the existing isToolCallEventType() pattern.

Inline 14 handler type aliases (SendMessageHandler, SetModelHandler, etc.)
directly into the ExtensionActions interface since they were only used there
and added no semantic value.

Update documentation examples to use the new unified guard.
2026-03-19 14:55:00 -03:00
frizynn
e01e994d82 refactor: consolidate duplicate patterns in LSP module
- Remove duplicate SYMBOL_KIND_NAMES from types.ts (keep SYMBOL_KIND_LABELS in utils.ts)
- Export which() from config.ts, import in lspmux.ts instead of duplicating
- Inline getLspServersForFile/getLspServerForFile thin wrappers in index.ts
- Extract formatLocationResults() helper for definition/type_definition/implementation
- Extract formatCallHierarchyResults() helper for incoming_calls/outgoing_calls
- Remove unused formatPosition() from utils.ts
2026-03-19 14:54:47 -03:00
Tom Boucher
8b0727c0e5 fix: accumulate session cost independently of message array (#1423)
getSessionStats() calculated cost by summing usage from assistant messages
in state.messages. After auto-compaction, pre-compaction messages are
replaced by a compactionSummary with no usage field — dropping the cost.

Fix: Added cumulative accumulators (_cumulativeCost, _cumulativeInputTokens,
_cumulativeOutputTokens, _cumulativeToolCalls) that are incremented on
every assistant message event, independent of the message array.
getSessionStats() now returns max(array-sum, cumulative) to ensure
monotonically non-decreasing values.

Fixes #1423
2026-03-19 12:44:11 -04:00
Tom Boucher
f0fe4b2443 fix: emit agent_end after abort during tool execution (#1414) (#1417)
* fix: sync worktree completion artifacts back to external state before merge (#1412)

When a worktree's .gsd/ was a real directory (not symlinked to external
state), milestone completion artifacts (SUMMARY, VALIDATION, updated
ROADMAP) were written locally but never synced back. The project root's
deriveState() read from external state and found no SUMMARY — reporting
the milestone as incomplete.

Changes:
- auto-worktree.ts: Added syncWorktreeStateBack() that copies milestone
  and slice .md files from worktree .gsd/ to the main external state dir
- auto.ts: Call syncWorktreeStateBack() in tryMergeMilestone before the
  git merge, ensuring artifacts are visible from the project root

Fixes #1412

* fix: emit agent_end after abort during tool execution (#1414)

When a user aborts a turn while a tool call is running, the abort RPC
succeeds but agent_end was never emitted. RPC consumers tracking turn
lifecycle via events got stuck in a 'streaming' state permanently.

Fix: After abort() + waitForIdle(), emit a synthetic agent_end if the
agent is no longer streaming. This ensures consumers always see the
turn-complete signal regardless of how the turn ended.

Fixes #1414
2026-03-19 10:24:39 -06:00
Jeremy McSpadden
d7bf3d4e72 Improve startup performance with lazy extension loading (#1336) 2026-03-19 07:38:50 -06:00
github-actions[bot]
d25c174f8b release: v2.33.1 2026-03-19 04:02:21 +00:00
github-actions[bot]
106f5d8d32 release: v2.33.0 2026-03-19 02:40:54 +00:00
github-actions[bot]
113c5e6518 release: v2.32.0 2026-03-19 00:15:12 +00:00
github-actions[bot]
a488de99bb release: v2.31.2 2026-03-18 22:40:20 +00:00
github-actions[bot]
f2b637a596 release: v2.31.1 2026-03-18 22:13:47 +00:00
github-actions[bot]
b095e352a7 release: v2.31.0 2026-03-18 21:40:31 +00:00
Jean-Dominique Stepek
acec5b5fda feat: add aws-auth extension for automatic Bedrock credential refresh (#1253)
Adds a new bundled extension that proactively checks and refreshes AWS
credentials for Bedrock model users.

Startup (session_start):
- Runs 'aws sts get-caller-identity' with the profile extracted from
  the configured awsAuthRefresh command
- If credentials are expired, runs the refresh command (e.g. aws sso login)
  before the user sends their first prompt
- Shows 'AWS Bedrock login confirmed ✓' when credentials are valid

Mid-session (before_provider_request):
- Re-verifies credentials every 15 minutes before Bedrock API calls
- Catches credential expiry during long sessions without needing retry logic

Zero changes to base files — the entire feature is a single extension file.
Only activates when awsAuthRefresh is set in settings.json and the current
model uses bedrock-converse-stream.
2026-03-18 15:07:10 -06:00
github-actions[bot]
558b2e1c10 release: v2.30.0 2026-03-18 20:26:29 +00:00
Tom Boucher
ebe59a987f fix: use shell: true for LSP spawn on Windows to resolve .cmd executables (#1233)
On Windows, executables like npx, tsc, and typescript-language-server
are .cmd batch scripts. Node.js's spawn() can't find them without
shell: true because it looks for exact binary names, not .cmd wrappers.
This caused ENOENT crashes during auto-mode when the LSP tried to
spawn npx tsc --noEmit for TypeScript diagnostics.

Added shell: true conditional on process.platform === 'win32' in the
LSP client's spawn call. Unix platforms are unaffected.

Fixes #1222
2026-03-18 13:55:23 -06:00
TÂCHES
28c741c196 refactor: replace MCPorter with native MCP client (#1210)
* refactor: replace MCPorter CLI with native MCP client using @modelcontextprotocol/sdk

MCPorter is a third-party global CLI that fails to install on many systems,
producing error noise on every startup. Replace it with a native extension
that uses the already-bundled @modelcontextprotocol/sdk Client class directly.

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

* docs: update README extension table from MCPorter to MCP Client

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

* fix: add .js suffix to MCP SDK subpath imports for NodeNext resolution

The SDK wildcard export (./*) requires .js suffix for TypeScript NodeNext
module resolution. Also add .js-suffixed virtual module keys so jiti
resolves them correctly in compiled Bun binaries.

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-18 12:26:16 -06:00
github-actions[bot]
d57b117aea release: v2.29.0 2026-03-18 17:44:12 +00:00
Tom Boucher
0f97f938f7 feat: add searchExcludeDirs setting for @ file autocomplete blacklist (#1202)
Implements the directory blacklist feature from #660 (incomplete items 3-4).

Users can now configure directories to exclude from the @ file picker
and fuzzy search via settings.json:

  { "searchExcludeDirs": ["node_modules", ".git", "dist", "build"] }

Changes:
- settings-manager.ts: added searchExcludeDirs setting with get/set
- autocomplete.ts (pi-tui): CombinedAutocompleteProvider accepts
  excludeDirs option, filters excluded directory names in both
  readdir-based and native fuzzy search paths
- interactive-mode.ts: passes searchExcludeDirs to the provider

The native fd fuzzy search already respects .gitignore. This setting
covers directories that aren't gitignored but shouldn't appear in
autocomplete (e.g., large vendor dirs, build outputs in projects
without comprehensive .gitignore).

Fixes #1190
2026-03-18 11:23:40 -06:00
Tom Boucher
1236919c39 fix: include promptGuidelines in customPrompt path of buildSystemPrompt (#1187)
When buildSystemPrompt() receives a customPrompt (as GSD's contract
provides), it returned early without appending promptGuidelines from
extension-registered tools. The tool definitions still reached the
API's tools parameter, but without prompt guidance the model didn't
know when to prefer them — causing subagent tools to be silently
ignored in favor of async_bash/bg_shell.

Added promptGuidelines append after date/time in the customPrompt
path, matching the behavior of the non-custom path.

Fixes #1184
2026-03-18 10:55:16 -06:00
Tom Boucher
4c98d3e708 fix: handle Windows non-ASCII paths in cpSync with copyFileSync fallback (#1181)
Node.js's cpSync fails on Windows when the path contains non-ASCII
characters (e.g. C:\Users\Görloff) due to the \\?\ extended-length path
prefix not handling Unicode correctly. This affects both the build
script (copy-assets.cjs) and the runtime resource sync (resource-loader.ts).

Added a try/catch fallback: when cpSync throws, fall back to a manual
recursive copy using copyFileSync which handles non-ASCII paths correctly.

Changed files:
- src/resource-loader.ts: syncResourceDir() catches cpSync failure and
  falls back to copyDirRecursive()
- packages/pi-coding-agent/scripts/copy-assets.cjs: all cpSync calls
  wrapped in safeCpSync() with the same fallback

Fixes #1178
2026-03-18 10:13:37 -06:00
Copilot
05beb9cba7 fix: text-based fallbacks for RPC mode where TUI widgets produce empty turns (#1112)
* Initial plan

* fix: add text-based fallbacks for RPC mode where TUI widgets produce empty turns

- rpc-mode.ts: Emit placeholder widget event instead of silently dropping factory-based setWidget calls
- commands.ts: handleStatus() falls back to text-based status summary when custom() returns undefined
- commands.ts: handleVisualize() notifies that TUI is required when custom() returns undefined
- auto-dashboard.ts: updateProgressWidget() emits string-array fallback before factory widget
- queue-reorder-ui.ts: showQueueReorder() notifies with current order when custom() returns undefined
- index.ts: Dashboard shortcut handler falls back to text status in RPC mode

Co-authored-by: glittercowboy <186001655+glittercowboy@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: glittercowboy <186001655+glittercowboy@users.noreply.github.com>
2026-03-18 08:34:49 -06:00
Tom Boucher
fa39a87465 fix(model-resolver): prefer provider's recommended variant over saved base model (#1131) 2026-03-18 08:23:56 -06:00