Commit graph

90 commits

Author SHA1 Message Date
scutifer
35ebe88870
feat: Call resolvePromptInput on the --system-prompt received on the CLI argument. This is needed to support file paths on the prompt (#287) 2025-12-23 13:06:40 +01:00
Mario Zechner
4492a3f304 Release v0.27.1 2025-12-22 19:28:26 +01:00
Mario Zechner
5d290f048e Fix SDK docs: AgentSession interface, findModel usage, settings example 2025-12-22 12:32:25 +01:00
Mario Zechner
62c64a286b Add project-specific settings and SettingsManager factories
- SettingsManager now loads .pi/settings.json from cwd (project settings)
- Project settings merge with global settings (deep merge for objects)
- Setters only modify global settings, project settings are read-only
- Add static factories: SettingsManager.create(cwd?, agentDir?), SettingsManager.inMemory(settings?)
- Add applyOverrides() for programmatic overrides
- Replace 'settings' option with 'settingsManager' in CreateAgentSessionOptions
- Update examples to use new pattern

Incorporates PR #276 approach
2025-12-22 12:23:02 +01:00
Mario Zechner
d67559a5e4 Remove unused fs import from main.ts 2025-12-22 01:42:52 +01:00
Mario Zechner
b168a6cae3 Add agentDir parameter to model config functions and OAuth storage
- loadAndMergeModels(agentDir) - loads models.json from agentDir
- getAvailableModels(agentDir) - uses agentDir for model discovery
- findModel(provider, id, agentDir) - uses agentDir for model lookup
- configureOAuthStorage(agentDir) - configures OAuth to use agentDir/oauth.json
- createAgentSession calls configureOAuthStorage with options.agentDir
- Export configureOAuthStorage from SDK
2025-12-22 01:42:27 +01:00
Mario Zechner
ace8ea3d5b Refactor SessionManager to use static factory methods
- Add factory methods: create(cwd), open(path), continueRecent(cwd), inMemory()
- Add static list(cwd) for session listing
- Make constructor private, pass cwd explicitly
- Update SDK to take sessionManager instead of sessionFile options
- Update main.ts to create SessionManager based on CLI flags
- Update SessionSelectorComponent to take sessions[] instead of SessionManager
- Update tests to use factory methods
2025-12-22 01:29:54 +01:00
Mario Zechner
7bf4c8ff24 Remove unnecessary section divider comments 2025-12-22 01:02:42 +01:00
Mario Zechner
6201bae805 Fix lint warnings in main.ts 2025-12-22 00:58:53 +01:00
Mario Zechner
67a5fbde15 Remove inline imports from main.ts 2025-12-22 00:58:36 +01:00
Mario Zechner
4398596d41 Refactor main.ts to use SDK createAgentSession
- Add continueSession, restoreFromSession, additionalHookPaths,
  additionalCustomToolPaths, scopedModels to CreateAgentSessionOptions
- Return CreateAgentSessionResult with session, customToolsResult,
  and modelFallbackMessage
- main.ts now focuses on CLI arg parsing and mode routing
- Reduced main.ts from ~490 to ~340 lines
2025-12-22 00:55:42 +01:00
Mario Zechner
bfc1c44791 Use SDK's discoverSlashCommands in main.ts 2025-12-22 00:48:47 +01:00
Mario Zechner
d95a5c4186 feat(coding-agent): add --skills CLI flag for filtering skills
Adds glob pattern support for skill filtering:
- --skills <patterns> CLI flag (comma-separated glob patterns)
- includeSkills setting in settings.json
- ignoredSkills now supports glob patterns
- ignoredSkills takes precedence over includeSkills and --skills

Closes #268
2025-12-21 20:58:54 +01:00
Nico Bailon
70440f7591
feat(coding-agent): add configurable skills directories (#269) 2025-12-21 20:48:40 +01:00
Mario Zechner
a81dc5eaca Add configurable OAuth storage backend and respect --models in model selector
- Add setOAuthStorage() and resetOAuthStorage() to pi-ai for custom storage backends
- Configure coding-agent to use its own configurable OAuth path via getOAuthPath()
- Model selector (/model command) now only shows models from --models scope when set
- Rewrite OAuth documentation in pi-ai README with examples

Fixes #255
2025-12-20 22:00:53 +01:00
Mario Zechner
b7c3cf9436 fix(coding-agent): clamp thinking level to model capabilities
- setThinkingLevel() now clamps xhigh to high when model doesn't support it
- Model changes automatically re-clamp the current thinking level
- Fixed /model command to use session.setModel() instead of agent.setModel()
- Footer and editor border color update after model/thinking changes

Closes #253
2025-12-20 09:52:57 +01:00
Nico Bailon
74f7e6c9d5
Wrap custom tools with hooks (#248) 2025-12-19 19:05:20 +01:00
Mario Zechner
4fb3af93fb Refactor subagent tool, fix custom tool discovery, fix JSON mode stdout flush
Breaking changes:
- Custom tools now require index.ts entry point in subdirectory
  (e.g., tools/mytool/index.ts instead of tools/mytool.ts)

Subagent tool improvements:
- Refactored to use Message[] from ai package instead of custom types
- Extracted agent discovery to separate agents.ts module
- Added parallel mode streaming (shows progress from all tasks)
- Added turn count to usage stats footer
- Removed redundant Query section from scout output

Fixes:
- JSON mode stdout flush: Fixed race condition where pi --mode json
  could exit before all output was written, causing consumers to
  miss final events

Also:
- Added signal/timeout support to pi.exec() for custom tools and hooks
- Renamed pi-pods bin to avoid conflict with pi
2025-12-19 04:54:02 +01:00
Peter Steinberger
d70edf571e
fix(coding-agent): detect image MIME via file-type (#205)
Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2025-12-17 17:11:56 +01:00
Mario Zechner
e7097d911a Custom tools with session lifecycle, examples for hooks and tools
- Custom tools: TypeScript modules that extend pi with new tools
  - Custom TUI rendering via renderCall/renderResult
  - User interaction via pi.ui (select, confirm, input, notify)
  - Session lifecycle via onSession callback for state reconstruction
  - Examples: todo.ts, question.ts, hello.ts

- Hook examples: permission-gate, git-checkpoint, protected-paths

- Session lifecycle centralized in AgentSession
  - Works across all modes (interactive, print, RPC)
  - Unified session event for hooks (replaces session_start/session_switch)

- Box component added to pi-tui

- Examples bundled in npm and binary releases

Fixes #190
2025-12-17 16:03:23 +01:00
Mario Zechner
03b061773c Release v0.22.4
- Add --list-models CLI flag for listing/finding models with fuzzy search

fixes #203
2025-12-17 00:39:14 +01:00
Nico Bailon
09bca9672f
Add skills system with Claude Code compatibility (#171)
* Add skills system with Claude Code compatibility

* consolidate skills into single module, merge loaders, add <available_skills> XML tags

* add Codex CLI skills compatibility, skip hidden/symlinks
2025-12-12 18:24:52 +01:00
Christian Catalan
f614892406
Add --version/-v flag to CLI (#170)
- Parse --version and -v flags in args.ts
- Handle version flag early in main.ts (print and exit)
- Add flag to help text
- Add comprehensive test coverage for CLI arg parsing

Co-authored-by: cc-vps <crcatala+vps@gmail.com>
2025-12-12 00:01:06 +01:00
Mario Zechner
7323af1f69 fixes #161: stop theme watcher and exit cleanly in print mode
The theme file watcher was keeping the Node.js process alive indefinitely
even in print mode where hot-reload is unnecessary. This simple fix calls
stopThemeWatcher() and process.exit(0) after print mode completes.

- Added stopThemeWatcher() call after runPrintMode() completes
- Added process.exit(0) to ensure clean process termination
- Imported stopThemeWatcher from theme module

This is a minimal fix that addresses the symptom (process hanging) without
changing the theme initialization logic.
2025-12-10 21:16:47 +01:00
Mario Zechner
9516424cae fixes #161: disable theme watcher in print mode
The theme file watcher was keeping the Node.js process alive indefinitely
even in print mode where hot-reload is unnecessary. This fix adds an
enableWatcher parameter to initTheme() and setTheme() functions, and only
enables watchers in interactive mode.

- Modified initTheme() to accept enableWatcher parameter (default: false)
- Modified setTheme() to accept enableWatcher parameter (default: false)
- Updated main.ts to only enable watchers in interactive mode
- Updated InteractiveMode to enable watchers when changing themes
2025-12-10 21:16:47 +01:00
Mario Zechner
7c553acd1e Add hooks system with pi.send() for external message injection
- Hook discovery from ~/.pi/agent/hooks/, .pi/hooks/, --hook flag
- Events: session_start, session_switch, agent_start/end, turn_start/end, tool_call, tool_result, branch
- tool_call can block execution, tool_result can modify results
- pi.send(text, attachments?) to inject messages from external sources
- UI primitives: ctx.ui.select/confirm/input/notify
- Context: ctx.exec(), ctx.cwd, ctx.sessionFile, ctx.hasUI
- Docs shipped with npm package and binary builds
- System prompt references docs folder
2025-12-10 00:50:30 +01:00
Mario Zechner
75c2eea151 Fix --session flag to load session messages and restore model/thinking 2025-12-09 01:59:20 +01:00
Mario Zechner
14d99b5f86 Move config.ts from utils/ to src/ 2025-12-09 01:28:06 +01:00
Mario Zechner
6c9a264b63 Remove old implementation files (main.ts, cli.ts, tui-renderer.ts), rename new files 2025-12-09 01:21:28 +01:00
Mario Zechner
83a6c26969 Reorganize file structure: core/, utils/, modes/interactive/components/, modes/interactive/theme/ 2025-12-09 00:51:33 +01:00
Mario Zechner
bd0d0676d4 Add bash mode for executing shell commands
- Add ! prefix in TUI editor to execute shell commands directly
- Output streams in real-time and is added to LLM context
- Supports multiline commands, cancellation (Escape), truncation
- Preview mode shows last 20 lines, Ctrl+O expands full output
- Commands persist in session history as bashExecution messages
- Add bash command to RPC mode via {type:'bash',command:'...'}
- Add RPC tests for bash command execution and context inclusion
- Update docs: rpc.md, session.md, README.md, CHANGELOG.md

Closes #112

Co-authored-by: Markus Ylisiurunen <markus.ylisiurunen@gmail.com>
2025-12-08 22:40:32 +01:00
Mario Zechner
00370cab39 Add xhigh thinking level for OpenAI codex-max models
- Add 'xhigh' to ThinkingLevel type in ai and agent packages
- Map xhigh to reasoning_effort: 'max' for OpenAI providers
- Add thinkingXhigh color token to theme schema and built-in themes
- Show xhigh option only when using codex-max models
- Update CHANGELOG for both ai and coding-agent packages

closes #143
2025-12-08 21:12:54 +01:00
Mario Zechner
7352072bc2 Run version check in parallel with TUI startup
Instead of blocking startup for up to 1 second waiting for the version check,
run it in the background and insert the notification into chat when it completes.
2025-12-05 23:36:06 +01:00
Mario Zechner
51195bc9fc Add authHeader option and fix print mode error handling
- Add 'authHeader' boolean option to models.json provider config
  When true, adds 'Authorization: Bearer <apiKey>' to model headers
  Useful for providers requiring explicit auth headers (fixes #81)

- Fix print mode (-p) silently failing on errors
  Now outputs error message to stderr and exits with code 1
  when assistant message has stopReason of error/aborted
2025-12-05 11:31:14 +01:00
Markus Ylisiurunen
ef8bb6c062 support appending content to the system prompt via cli argument 2025-12-05 09:25:10 +02:00
Mario Zechner
c3f63dd243 feat(coding-agent): add auto-compaction to RPC mode, add RPC compaction test
- RPC mode now auto-compacts when context exceeds threshold (same as TUI)
- Add RPC test for manual compaction via compact command
- Auto-compaction emits compaction event with auto: true flag
2025-12-04 02:49:22 +01:00
Mario Zechner
79731249eb Context compaction: commands, auto-trigger, RPC support, /branch rework (fixes #92)
- Add compaction settings to Settings interface
- /compact [instructions]: manual compaction with optional focus
- /autocompact: toggle auto-compaction on/off
- Auto-compaction triggers after assistant message_end when threshold exceeded
- Footer shows (auto) when auto-compact is enabled
- RPC mode: {type: 'compact'} command emits CompactionEntry
- /branch now reads from session file to show ALL historical user messages
- createBranchedSessionFromEntries preserves compaction events
2025-12-04 00:25:53 +01:00
Mario Zechner
e82fb0fc83 feat(coding-agent): configurable app name and config dir for forks (#95)
- Add piConfig to package.json for app name and config directory
- Consolidate paths.ts into config.ts with clearer naming
- Fix Bun binary detection (changed from %7EBUN to $bunfs)
- Update all hardcoded paths to use config.ts exports
- getThemesDir() for built-in themes, getCustomThemesDir() for user themes
2025-12-03 16:18:59 +01:00
Mario Zechner
c4a65ad8b9 feat: standalone binary support with Bun
- Add build:binary script for Bun compilation
- Add paths.ts for cross-platform asset resolution (npm/bun/tsx)
- Add GitHub Actions workflow for automated binary releases
- Update README with installation options

Based on #89 by @steipete
2025-12-02 12:18:42 +01:00
Mario Zechner
7a1884f85c Release v0.11.5 2025-12-01 20:22:14 +01:00
Mario Zechner
d2b60f11eb fix: RPC mode session management not saving sessions
Since version 0.9.0, RPC mode (--mode rpc) was not saving messages to
session files. The agent.subscribe() call with session management logic
was only present in the TUI renderer after it was refactored.

RPC mode now properly saves sessions just like interactive mode.

Added test for RPC mode session management to prevent regression.

Fixes #83

Thanks @kiliman for reporting this issue!
2025-12-01 01:19:17 +01:00
Mario Zechner
8900897840 feat(coding-agent): add --export CLI flag to convert session files to HTML
Closes #80
2025-11-29 23:05:07 +01:00
Mario Zechner
186169a820 feat(coding-agent): add read-only exploration tools (grep, find, ls) and --tools flag
Add grep, find, and ls tools for safe code exploration without modification risk.
These tools are available via the new --tools CLI flag.

- grep: Uses ripgrep (auto-downloaded) for fast regex searching. Respects .gitignore,
  supports glob filtering, context lines, and hidden files.
- find: Uses fd (auto-downloaded) for fast file finding. Respects .gitignore, supports
  glob patterns, and hidden files.
- ls: Lists directory contents with proper sorting and directory indicators.
- --tools flag: Specify available tools (e.g., --tools read,grep,find,ls for read-only mode)
- Dynamic system prompt adapts to selected tools with relevant guidelines

Closes #74
2025-11-29 00:59:23 +01:00
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
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
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
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
e1856daf57 fix: rename pi-agent to pi-agent-core (npm deprecation issue) 2025-11-21 22:20:43 +01:00
Mario Zechner
56450a4f19 fix(coding-agent): suppress informational output in non-interactive modes
In -p, --mode json, and --mode rpc modes, don't print informational
messages like 'Loaded project context from:' or model restore messages.
Only the actual output should be printed.
2025-11-21 22:07:17 +01:00
Mario Zechner
e89e657045 feat(coding-agent): allow starting CLI with prompt in interactive mode (#46)
BREAKING CHANGE: Passing a prompt on the command line now starts interactive
mode with the prompt pre-submitted, instead of exiting after completion.
Use --print or -p to get the previous non-interactive behavior.

- Add --print / -p flag for non-interactive mode
- Update runInteractiveMode to accept initial messages
- Update README documentation
- Fix Model Selection Priority docs to include --models scope
2025-11-21 21:57:35 +01:00