Commit Graph

1485 Commits

Author SHA1 Message Date
can1357 2be354322d chore: renamed package scope to @oh-my-pi for consistent branding
- Renamed npm package scope from @mariozechner to @oh-my-pi across all packages for consistent branding.
- Removed packages/pods directory and all related pod management functionality.
- Updated import paths and module declarations throughout codebase to reflect new package names.
- Reformatted code with consistent trailing comma removal and ternary operator alignment.
2026-01-02 18:08:23 +01:00
can1357 560c9670a8 feat: added MCP support and plugin system for external tool integration
- Added MCP (Model Context Protocol) support with stdio and HTTP transports for external tool integration.
- Implemented plugin system with install, enable, configure, and doctor commands for extensibility.
- Added 22 Exa MCP tools for web search, LinkedIn, company research, and websets operations.
- Introduced LSP tool with rust-analyzer support for code intelligence (diagnostics, hover, references, code actions).
- Added task tool for delegating work to specialized subagents with parallel execution support.
- Implemented web_search and web_fetch tools with Anthropic and Perplexity provider support.
2026-01-02 17:54:42 +01:00
can1357 aa37aafde8 build: added dev:install script to streamline workspace setup
- Added dev:install script to streamline local development setup across all workspace packages.
2026-01-02 15:13:27 +01:00
can1357 36467c2a57 feat(coding-agent): added git context to system prompt for repo awareness
- Added git context loading to system prompt to provide AI with repository state awareness.
- Implemented automatic detection of main/master branch to support varied repository conventions.
- Included current branch, git status, and recent commits snapshot for contextual understanding.
2026-01-02 15:12:32 +01:00
can1357 47c6849a5a feat(tui): added emergency terminal restore to prevent corrupted state on crashes
- Added emergency terminal restore function to reset terminal state on crashes without requiring instance access.
- Implemented crash handlers for SIGTERM, SIGHUP, uncaught exceptions, and unhandled rejections to ensure clean terminal exit.
- Added active terminal tracking to enable blind restore when no instance is available.
2026-01-02 15:10:14 +01:00
can1357 cf5c4286f1 feat(tui): overhauled UI with welcome screen and powerline footer
- Implemented a new welcome screen component for startup.
- Introduced a powerline-style footer with integrated git status, model info, and token usage.
- Consolidated extension loading messages into a new `/status` command.
- Added `?` hotkey to display shortcuts when the editor is empty.
2026-01-02 15:05:36 +01:00
can1357 b85d3f6aa4 merge(pi/main): integrate upstream changes through v0.31.1
Merged 53 commits from pi/main including:
- Export HTML rewrite with tree sidebar and /share command
- Hooks API enhancements (custom status, editor, session management)
- Edit diff preview before tool execution
- TUI fixes (Unicode format chars, OSC 8 hyperlinks, emoji optimization)
- Gemini CLI rate limit retry with server-provided delay
- Various bug fixes and documentation updates

Resolved conflicts by preserving Bun migration (spawn→Bun.spawn,
fs→Bun.file) while accepting upstream's new features and APIs.
2026-01-02 14:34:27 +01:00
can1357 1cee37cf92 build: migrated from Node.js to Bun for native TypeScript support
- Migrated from Node.js to Bun runtime to leverage native TypeScript execution and faster startup times.
- Replaced npm with bun package manager and updated lockfile format.
- Converted Node.js APIs (child_process, fs, readline) to Bun equivalents across all packages.
- Updated shebang lines from node/tsx to bun for CLI entry points.
- Removed TypeScript build step by using source files directly as package entry points.
- Updated CI workflows to use Bun instead of Node.js for installation and testing.
2026-01-02 13:46:05 +01:00
Mario Zechner 97d081a298 fix(ai): add retry with server-provided delay for Gemini CLI rate limits, fixes #370 2026-01-02 10:45:59 +01:00
Mario Zechner 0298084a97 Add [Unreleased] section for next cycle 2026-01-02 10:39:42 +01:00
Mario Zechner e32667781b Release v0.31.1 2026-01-02 10:39:08 +01:00
Mario Zechner 7396b1e3c4 fix: export type guard functions at runtime, fixes #397 2026-01-02 10:37:28 +01:00
cursive 19dad587b8 fix(tui): Strip OSC 8 hyperlink sequences in visibleWidth (#396) 2026-01-02 10:32:36 +01:00
Armin Ronacher 5c8f7344d4 Fix arrow key in model selector prior to model loading (#398) 2026-01-02 10:31:48 +01:00
Mario Zechner d572cd2886 Add [Unreleased] section for next cycle 2026-01-02 02:00:36 +01:00
Mario Zechner d301eabe13 Release v0.31.0 2026-01-02 01:59:59 +01:00
Mario Zechner 3eb55518eb Fix edit tool failing on files with UTF-8 BOM
Strip BOM before matching (LLM won't include invisible BOM in oldText),
restore on write.

Based on #394 by @prathamdby
2026-01-02 01:57:24 +01:00
nathyong 32ddfe684a tui: only check for emojis in visibleWidth when necessary
The initial render of a session, and any re-draws caused by terminal
resizing are noticeably slow, especially on conversations with 20+
turns and many tool calls.

From profiling with `bun --cpu-prof` (available since bun 1.3.2), the
majority of the rendering (90%) is spent on detection of emojis in the
string-width library, running the expensive `/\p{RGI_Emoji}$/v`
regular expression on every individual grapheme cluster in the entire
scrollback. I believe it essentially expands to a fixed search against
every possible emoji sequence, hence the amount of CPU time spent in it.

This change replaces the `stringWidth` from string-width with a
`graphemeWidth` function that performs a similar check, but avoids
running the `/\p{RGI_Emoji}$/v` regex for emoji detection unless it
contains codepoints that could be emojis.

The `visibleWidth` function also has two more optimisations:
- Short-circuits string length detection for strings that are entirely
  printable ASCII characters
- Adds a cache for non-ASCII segments to avoid recomputing string length
  when resizing
2026-01-02 01:56:11 +01:00
Mario Zechner cc397427b9 Update docs for ctx.ui.editor() and handoff example
- Added ctx.ui.editor() to hooks.md and custom-tools.md
- Added ctx.ui.editor() to CHANGELOG.md
- Added handoff.ts to examples/hooks/README.md
2026-01-02 01:26:21 +01:00
Mario Zechner b3c416d556 Fix BorderedLoader to pass theme to DynamicBorder
BorderedLoader receives theme as a parameter but was creating
DynamicBorder() without passing it, causing DynamicBorder to
fall back to the global theme variable which is undefined when
loaded via jiti (separate module cache).

Added doc comment to DynamicBorder explaining the jiti issue.
2026-01-02 01:21:07 +01:00
Mario Zechner bb5070171b Fix DynamicBorder crash when theme not initialized
Make DynamicBorder defensive against undefined theme by checking
at render time instead of relying on default parameter closure.
2026-01-02 01:15:45 +01:00
Mario Zechner d8b94822c8 fix(coding-agent): prevent full re-renders during write tool streaming
Move line count from header to footer to avoid changing the first line
during streaming, which was triggering full screen re-renders in the
TUI's differential rendering logic.
2026-01-02 01:11:06 +01:00
Mario Zechner fbada4e653 Use serializeConversation in handoff hook
Properly handles all message types including tool calls, thinking,
and tool results instead of manual text extraction.
2026-01-02 00:45:03 +01:00
Mario Zechner 2314cb0930 Add handoff example hook
Transfers context to a new focused session instead of compacting.
User provides a goal, hook generates a prompt with relevant context,
creates a new session with parent tracking, and loads the prompt
as a draft in the editor for review.

Inspired by Amp's handoff feature.
2026-01-02 00:42:11 +01:00
Mario Zechner 4b0e345353 Remove unnecessary comments from types 2026-01-02 00:39:54 +01:00
Mario Zechner 1ed86c8bd1 Add Clawd summary comments to hook and custom tool types 2026-01-02 00:32:38 +01:00
Mario Zechner bfdfb96bf8 Add agent state methods to CustomToolContext and fix abort signature
CustomToolContext now has:
- isIdle() - check if agent is streaming
- hasQueuedMessages() - check if user has queued messages
- abort() - abort current operation (fire-and-forget)

Changed abort() signature from Promise<void> to void in both
HookContext and CustomToolContext. The abort is fire-and-forget:
it calls session.abort() without awaiting, so the abort signal
is set immediately while waitForIdle() runs in the background.

Fixes #388
2026-01-02 00:31:23 +01:00
Mario Zechner 321462bda7 Split HookContext and HookCommandContext to prevent deadlocks
HookContext (all events):
- isIdle() - read-only state check
- hasQueuedMessages() - read-only state check
- abort() - fire-and-forget, does not wait

HookCommandContext (slash commands only):
- waitForIdle() - waits for agent to finish
- newSession(options?) - create new session
- branch(entryId) - branch from entry
- navigateTree(targetId, options?) - navigate session tree

Session control methods moved from HookAPI (pi.*) to HookCommandContext (ctx.*)
because they can deadlock when called from event handlers that run inside
the agent loop (tool_call, tool_result, context events).
2026-01-02 00:24:58 +01:00
Mario Zechner cd7df64220 Add session management and agent state methods to hooks API
HookAPI additions:
- pi.newSession(options?) - create new session with optional setup callback
- pi.branch(entryId) - branch from a specific entry
- pi.navigateTree(targetId, options?) - navigate the session tree

HookContext additions:
- ctx.isIdle() - check if agent is streaming
- ctx.waitForIdle() - wait for agent to finish
- ctx.abort() - abort current operation
- ctx.hasQueuedMessages() - check for queued user messages

These enable hooks to programmatically manage sessions (handoff, templates)
and check agent state before showing interactive UI.

Fixes #388
2026-01-01 23:56:24 +01:00
Mario Zechner f107f980c9 Consolidate session events: remove session_before_new/session_new, add reason field to switch events
- Remove session_before_new and session_new hook events
- Add reason: 'new' | 'resume' to session_before_switch and session_switch events
- Remove 'new' reason from custom tool onSession (use 'switch' for both /new and /resume)
- Rename reset() to newSession(options?) in AgentSession
- Add NewSessionOptions with optional parentSession for lineage tracking
- Rename branchedFrom to parentSession in SessionHeader
- Rename RPC reset command to new_session with optional parentSession
- Update example hooks to use new event structure
- Update documentation and changelog

Based on discussion in #293
2026-01-01 23:31:26 +01:00
Mario Zechner 33cea88fca Fix crash on Unicode format characters in visibleWidth
Strip all Unicode format characters (category Cf) before passing to
string-width. These are invisible control characters that crash
string-width but have no visible width anyway.

Closes #390
2026-01-01 22:33:09 +01:00
Mario Zechner 7cc7150125 Remove extra spacer before loader in BorderedLoader 2026-01-01 22:30:19 +01:00
Mario Zechner b5b18991a3 Add CHANGELOG entries for export theme colors and syntax highlighting 2026-01-01 22:28:44 +01:00
Mario Zechner 06ae57b2c9 Add theme-configurable HTML export colors (from PR #387)
- Add optional 'export' section to theme JSON with pageBg, cardBg, infoBg
- If not specified, colors are auto-derived from userMessageBg
- Add export colors to dark.json and light.json
- Update theme-schema.json and TypeBox schema
- Add documentation to docs/theme.md
- Add margin-top back to tool-output for spacing between header and content
2026-01-01 22:21:40 +01:00
Mario Zechner 424401f426 Fix markdown code block default color to use --text not --mdCodeBlock
The mdCodeBlock color was being applied to all text in code blocks,
overriding hljs syntax highlighting for unspanned text.
2026-01-01 22:15:26 +01:00
Mario Zechner 6130518f60 Fix hljs v11 compound class selectors for functions/types 2026-01-01 22:07:04 +01:00
Mario Zechner 98d56b15d7 Fix hljs color mappings to match TUI theme
- Add .hljs-function for syntaxFunction
- Separate .hljs-punctuation to use syntaxPunctuation (was using syntaxOperator)
2026-01-01 22:04:38 +01:00
Mario Zechner a46024a5ff Fix HTML escaping in markdown code blocks
Move HTML tag escaping from pre-parse to custom renderers.
This preserves < in code blocks while still escaping in text content.
2026-01-01 22:03:01 +01:00
Mario Zechner 7720f3512b Add ctx.ui.theme getter for styling status text with theme colors
- Add theme property to HookUIContext interface
- Implement in interactive, RPC, and no-op contexts
- Add status-line.ts example hook
- Document styling with theme colors in hooks.md
2026-01-01 21:58:01 +01:00
Mario Zechner aa632c295d Remove test files, add out.html to gitignore 2026-01-01 21:50:32 +01:00
Mario Zechner 8e42104f9a Remove padding from markdown code blocks 2026-01-01 21:50:23 +01:00
Mario Zechner 5ad56dfccc Remove accidentally committed files 2026-01-01 21:42:28 +01:00
Mario Zechner 31ab52e752 Fix markdown code block syntax highlighting
Marked v15 removed the highlight option from setOptions.
Use marked.use() with a custom renderer instead.
2026-01-01 21:42:18 +01:00
Mario Zechner bc7c0d9af9 Update todo.md 2026-01-01 21:40:36 +01:00
Mario Zechner 42205e6636 Fix tool-output spacing by removing pre-wrap from container
The white-space: pre-wrap on .tool-output was preserving template
literal whitespace (newlines and indentation). The pre elements
inside still have pre-wrap for actual code content.
2026-01-01 21:40:16 +01:00
Prateek Sunal 8319bd530e Hooks can render custom status (#385)
* Add ctx.ui.setStatus(key, text) API for hooks to display status in footer

- Add setStatus to HookUIContext interface
- Implement in interactive mode (FooterComponent)
- Implement in RPC mode (fire-and-forget)
- Add no-op implementations for headless contexts
- Multiple statuses displayed on single line, sorted by key
- Supports ANSI styling (hooks handle their own colors)

* Remove setStatus from changelog for now

* Fix hook status API to follow TUI rules

- Sanitize status text: replace newlines, tabs, carriage returns with spaces
- Truncate combined status line to terminal width using truncateToWidth
- Update JSDoc to document sanitization and truncation behavior
- Remove unused createHookUIContext method
- Add missing setStatus to test mock

* Add setStatus to changelog

* Use dim ellipsis for hook status truncation for consistency with footer style

---------

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-01-01 21:35:37 +01:00
Mario Zechner ae4c7b2794 Fix export HTML styling issues
- Match help-bar font size (11px) with header-info
- Add newline after 'Available Tools' header
- Remove excessive margin-top from tool-output
2026-01-01 21:34:07 +01:00
Mario Zechner 7ff3a23bdf Add /share command to README 2026-01-01 21:28:22 +01:00
Mario Zechner 24cdb8a34b Make /share cancellable with Escape, add CHANGELOG entries
- Use BorderedLoader for /share command so Escape cancels gist creation
- Add CHANGELOG entries for /share command and HTML export improvements
- Add todo.md with remaining export-html issues
2026-01-01 21:27:33 +01:00
Mario Zechner 5b173ffaa1 Remove unused imports and variables 2026-01-01 21:14:36 +01:00