Commit graph

540 commits

Author SHA1 Message Date
Mario Zechner
a61eca5dee fix: file @ autocomplete performance using fd
- Replace slow synchronous directory walking with fd for fuzzy file search
- Auto-download fd to ~/.pi/agent/tools/ if not found in PATH
- Performance improved from ~900ms to ~10ms per keystroke on large repos
- Remove minimatch dependency from tui package
- Graceful degradation if fd unavailable (empty results)

Fixes #69
2025-11-28 23:38:44 +01:00
Mario Zechner
754e745b1f Restore prompt to editor on API key validation failure
fixes #77
2025-11-28 23:00:37 +01:00
Mario Zechner
4830a9cf40 Release v0.10.2 2025-11-27 23:59:15 +01:00
Mario Zechner
8b1cca8279 coding-agent: remove identity override from system prompt (#73)
Models now use their native identity instead of being told they are Pi.
2025-11-27 23:57:02 +01:00
Mario Zechner
0397dd44c8 coding-agent: add pi-session- prefix to exported HTML files (#72)
Makes exported session files easier to filter with .gitignore
2025-11-27 23:54:10 +01:00
Mario Zechner
9ebee631be mom: turn-based context, timestamp fixes, system prompt improvements (#68)
Breaking Changes:
- Timestamps now use Slack format - run migrate-timestamps.ts for existing logs

Added:
- Channel/user ID mappings in system prompt
- Skills documentation in system prompt
- Debug last_prompt.txt output
- Bash working directory info
- Token-efficient log queries filtering tool calls

Changed:
- Turn-based message context (groups consecutive bot messages as one turn)
- Messages sorted by Slack timestamp
- Condensed system prompt (~5k → ~2.7k chars)
- Simplified user prompt
- Selective logging (skip UI status labels)

Fixed:
- Duplicate message logging from app_mention handler
- Username obfuscation in thread messages
2025-11-27 23:45:25 +01:00
Mario Zechner
330e044b55 feat(mom): split long messages instead of truncating
- Messages > 40k chars are split into multiple Slack messages
- Full tool results now shown in thread (no truncation)
- Main message truncates with 'see thread for full response' if too long
- Keep jsonl log truncation for storage efficiency
2025-11-27 19:32:54 +01:00
Mario Zechner
4f845cdd1b fix(mom): handle Slack message length limits and API errors gracefully
- Truncate messages exceeding Slack's 40,000 char limit
- Catch Slack API errors in queue and post to thread instead of crashing
- Add error context to queue operations for better debugging
- Wrap replaceMessage in try/catch
2025-11-27 19:22:53 +01:00
Mario Zechner
0e95592eb7 Release v0.10.1 2025-11-27 14:18:29 +01:00
Mario Zechner
5fcdf0cfd8 feat(mom): add arrow prefix to tool labels for visual distinction
Closes #65
2025-11-27 14:11:08 +01:00
Mario Zechner
effb4d0b7c feat(mom): reduce tool verbosity in main Slack messages
- During execution: show tool labels, thinking, and text in main message
- After completion: replace main message with only final assistant text
- Post thinking (italic) and text to thread for full audit trail
- Add promise queue to ensure ctx.respond calls execute sequentially
- Add log.logThinking() and log.logResponse() for console output
- Get final text from agent.state.messages instead of tracking

Closes #65
2025-11-27 14:07:21 +01:00
Mario Zechner
318254bff4 feat: show git branch in footer
- Footer now displays active git branch after directory path (e.g., ~/project (main))
- Branch detected by reading .git/HEAD directly (fast, synchronous)
- Cache refreshed after each assistant message to detect branch changes
- Handles normal branches, detached HEAD, and non-git repos

Closes #55
2025-11-27 12:56:45 +01:00
Mario Zechner
f95f41b1c4 Add CLI file arguments support via @file prefix
Implements ability to include files directly in the initial message using @ prefix.

Features:
- All @file arguments are coalesced into the first user message
- Text files wrapped in <file name="path">content</file> tags
- Images (.jpg, .jpeg, .png, .gif, .webp) attached as base64-encoded attachments
- Supports ~ expansion, relative and absolute paths
- Empty files are skipped silently
- Non-existent files cause immediate error with clear message
- Works in interactive, --print, and --mode text/json modes
- Not supported in --mode rpc (errors with clear message)

Examples:
  pi @prompt.md @image.png "Do this"
  pi --print @code.ts "Review this code"
  pi @requirements.md @design.png "Implement this"

Closes #54
2025-11-27 12:47:11 +01:00
Mario Zechner
48df1ff259 Improved HTML export with timestamps, better styling, and comprehensive stats
- Added timestamps to each user and assistant message (HH:MM:SS format)
- Fixed text clipping issues with comprehensive word-wrapping CSS
- Improved font selection: ui-monospace, Cascadia Code, Source Code Pro
- Reduced font sizes for more compact display (12px base, down from 14px)
- Added model switch indicators in conversation timeline with subtle background
- Created dedicated Tokens & Cost section showing:
  - Cumulative input/output/cache read/write tokens
  - Cost breakdown by token type with 4 decimal precision
  - Total cost in bold
  - Context usage with token count, percentage, and model identification
- Now displays all unique models used during session (not just initial model)
- Made Messages section more compact (reduced gaps, removed redundant fields)

Closes #51
Closes #52
2025-11-27 12:32:45 +01:00
Mario Zechner
ca0a86b981 Fix editor cursor navigation for wrapped lines, add word navigation
- Up/down arrows now navigate visual (wrapped) lines instead of logical lines
- Fixed double cursor display at wrap boundaries
- Added word by word navigation via Option+Left/Right or Ctrl+Left/Right
- Updated README keyboard shortcuts documentation

Closes #61
2025-11-27 12:08:36 +01:00
Mario Zechner
a59553a881 Fix edit diff line number alignment and whitespace preservation
- Fix line numbers showing incorrect values for edits far from file start
  (e.g., 1,2,3 instead of 336,337,338). Skip count was added after displaying
  lines instead of before.

- Rewrite splitIntoTokensWithAnsi in pi-tui to preserve whitespace as separate
  tokens instead of discarding it. Wrapped lines now maintain proper alignment
  and code indentation.

- Update mom README: rename title, remove em-dashes for cleaner prose
2025-11-27 11:53:00 +01:00
Mario Zechner
932f48b0e9 Release v0.10.0 2025-11-27 01:33:50 +01:00
Mario Zechner
daecee70d7 Add biome check to mom package check script 2025-11-27 01:31:13 +01:00
Mario Zechner
384e4a3a7d feat: fuzzy file search with @ prefix
- Type @ to fuzzy-search files/folders across project
- Respects .gitignore and skips hidden files
- Pure Node.js implementation using readdir with withFileTypes
- No external dependencies (fd/find) required
- Also optimized Tab completion to use withFileTypes instead of statSync

Based on PR #60 by @fightbulc, reimplemented for performance.
2025-11-27 00:59:12 +01:00
Mario Zechner
4de46fbab3 fix: suppress stderr in execSync calls to prevent TUI corruption
Added stdio: 'pipe' to all execSync calls in fuzzy file search to prevent
stderr output from fd/fdfind command checks from corrupting TUI rendering.
2025-11-27 00:13:06 +01:00
Mario Zechner
c2db2f9f4a Merge branch 'main' into pr-60-fuzzy-search 2025-11-27 00:07:48 +01:00
Tino Ehrich
15d5120b6a added support for finding folders as well 2025-11-27 00:06:59 +01:00
Tino Ehrich
b8e5f8db6d feat: Fuzzy search via 2025-11-27 00:06:54 +01:00
Mario Zechner
053800e9f3
Merge pull request #59 from kiliman/kiliman/rpc-attachments
fix: pass attachments to agent prompt from RPC interface
2025-11-26 23:58:51 +01:00
Mario Zechner
138d111b05 remove debug file 2025-11-26 23:55:35 +01:00
Mario Zechner
e7c48e33a2 fix: emoji text wrapping crash in pi-tui
Fixed crash when rendering text containing emojis followed by long content.
The breakLongWord function was iterating over UTF-16 code units instead of
grapheme clusters, causing emojis (surrogate pairs) to be miscounted during
line wrapping. Now uses Intl.Segmenter to properly handle multi-codepoint
characters.
2025-11-26 23:55:01 +01:00
Mario Zechner
5b940c2686 docs: clarify that AGENTS.md files are loaded at every startup
Removed confusing parenthetical that suggested context files aren't loaded when continuing/resuming sessions. They are always freshly loaded from disk at startup - the parenthetical only applied to console logging behavior.
2025-11-26 23:41:52 +01:00
Mario Zechner
0af6742604 Restructure mom README: improve flow, clarify concepts, enhance security section 2025-11-26 23:22:43 +01:00
Mario Zechner
0c6c0f34dd mom: add working indicator and improve stop command
Working Indicator:
- Add '...' to channel messages while mom is processing
- Automatically removed when work completes or stops
- Applies to working message, not status messages

Improved Stop Command:
- Posts separate 'Stopping...' message that updates to 'Stopped'
- Original working message continues updating with tool results
- Clean separation between status and work output
- Properly handles abort during multi-step operations

Clean Stop Reason Handling:
- Agent run() now returns { stopReason } instead of throwing
- Handle 'aborted', 'error', 'stop', 'length', 'toolUse' cases cleanly
- No more exception-based control flow
- Track stopReason from assistant message.stopReason field

New SlackContext Methods:
- replaceMessage() - replace message text instead of appending
- setWorking() - add/remove working indicator
- Improved context tracking for stop command updates
2025-11-26 20:49:02 +01:00
Mario Zechner
bfe7df6a49 fix: biome linter warnings (unused parameters) 2025-11-26 18:04:37 +01:00
Mario Zechner
213bc4df1c mom: add centralized logging, usage tracking, and improve prompt caching
Major improvements to mom's logging and cost reporting:

Centralized Logging System:
- Add src/log.ts with type-safe logging functions
- Colored console output (green=user, yellow=mom, dim=details)
- Consistent format: [HH:MM:SS] [context] message
- Replace scattered console.log/error calls throughout codebase

Usage Tracking & Cost Reporting:
- Track tokens (input, output, cache read/write) and costs per run
- Display summary at end of each run in console and Slack thread
- Example: 💰 Usage: 12,543 in + 847 out (5,234 cache read) = $0.0234

Prompt Caching Optimization:
- Move recent messages from system prompt to user message
- System prompt now mostly static (only changes with memory files)
- Enables effective use of Anthropic's prompt caching
- Significantly reduces costs on subsequent requests

Model & Cost Improvements:
- Switch from Claude Opus 4.5 to Sonnet 4.5 (~40% cost reduction)
- Fix Claude Opus 4.5 cache pricing in ai package (was 3x too expensive)
- Add manual override in generate-models.ts until upstream fix merges
- Submitted PR to models.dev: https://github.com/sst/models.dev/pull/439

UI/UX Improvements:
- Extract actual text from tool results instead of JSON wrapper
- Cleaner Slack thread formatting with duration and labels
- Tool args formatting shows paths with offset:limit notation
- Add chalk for colored terminal output

Dependencies:
- Add chalk package for terminal colors
2025-11-26 18:04:16 +01:00
Mario Zechner
82d4ac93e1 ai: update models list (removed grok-4.1-fast non-free variant) 2025-11-26 13:21:59 +01:00
Mario Zechner
4e01eca40e mom: add working memory system and improve log querying
- Add MEMORY.md files for persistent working memory
  - Global memory: workspace/MEMORY.md (shared across channels)
  - Channel memory: workspace/<channel>/MEMORY.md (channel-specific)
  - Automatically loaded into system prompt on each request

- Enhance JSONL log format with ISO 8601 dates
  - Add 'date' field for easy grepping (e.g., grep '"date":"2025-11-26"')
  - Migrated existing logs to include date field

- Improve log query efficiency
  - Add jq query patterns to prevent context overflow
  - Emphasize limiting NUMBER of messages (10-50), not truncating text
  - Show full message text and attachments in queries
  - Handle null/empty attachments with (.attachments // [])

- Optimize system prompt
  - Add current date/time for date-aware operations
  - Format recent messages as TSV (43% token savings vs raw JSONL)
  - Add efficient query examples with both JSON and TSV output

- Enhanced security documentation
  - Add prompt injection risk warnings
  - Document credential exfiltration scenarios
  - Provide mitigation strategies
2025-11-26 13:21:43 +01:00
kiliman
958d265112 fix: pass attachments to agent prompt from RPC interface
This PR updates the call to `agent.prompt` with the `attachments` prop provided in the JSON input.
2025-11-25 21:56:32 -05:00
Mario Zechner
a484330cd1 v0.9.4: Mom Slack bot with Docker sandbox 2025-11-26 01:50:28 +01:00
Mario Zechner
30964e0c33 mom: Thread-based tool details, improved README, fixed message ordering 2025-11-26 01:48:41 +01:00
Mario Zechner
f53e4fba42 mom: Add scratchpad directory to system prompt 2025-11-26 01:22:47 +01:00
Mario Zechner
6117127b02 mom: Single accumulated message per run, exclude data dir from biome 2025-11-26 01:21:45 +01:00
Mario Zechner
9e0255b10b mom: Tell mom what environment she's in (Docker vs host) 2025-11-26 01:09:43 +01:00
Mario Zechner
f140f2e432 mom: Docker sandbox support with --sandbox=docker:container-name option 2025-11-26 01:06:00 +01:00
Mario Zechner
da26edb2a7 mom: remove data dir from git, add to gitignore 2025-11-26 00:28:08 +01:00
Mario Zechner
aa9e058249 mom: Slack bot with abort support, streaming console output, removed sandbox 2025-11-26 00:27:21 +01:00
Mario Zechner
a7423b954e Merge pull request #57 from badlogic/feature/footer-cost-dollar-sign
Add $ prefix to cost in footer
2025-11-25 21:35:18 +01:00
Mario Zechner
b42df6848c Add $ prefix to cost in footer
Fixes #53
2025-11-25 21:32:52 +01:00
Mario Zechner
0148f0ac3d v0.9.3: Added Anthropic Claude Opus 4.5 support 2025-11-24 21:03:32 +01:00
Mario Zechner
2918d871c7 Update package-lock.json 2025-11-24 19:46:32 +01:00
Mario Zechner
52325adb97 Release v0.9.2 2025-11-24 19:32:55 +01:00
Mario Zechner
68ca83441b Changes to AGENTS.md 2025-11-24 19:17:50 +01:00
Mario Zechner
18db1fd6eb Changes for AGENTS.md 2025-11-24 19:00:28 +01:00
Mario Zechner
7ff3e572a4 clean-up 2025-11-24 18:41:45 +01:00