Mario Zechner
56ef0e63f3
Session tree: simplify types, add branching API, comprehensive tests
...
Types:
- SessionEntryBase with type field, extended by all entry types
- CustomEntry for hooks (type: 'custom', customType, data)
- Remove XXXContent types and TreeNode (redundant)
API:
- Rename saveXXX to appendXXX with JSDoc explaining tree semantics
- Rename branchInPlace to branch() with better docs
- Add createBranchedSession(leafId) replacing index-based version
- Add getTree() returning SessionTreeNode[] for tree traversal
- Add appendCustomEntry(customType, data) for hooks
Tests:
- tree-traversal.test.ts: 28 tests covering append, getPath, getTree,
branch, branchWithSummary, createBranchedSession
- save-entry.test.ts: custom entry integration
Docs:
- Class-level JSDoc explaining append-only tree model
- Method docs explaining leaf advancement and branching
- CHANGELOG.md entry for all changes
2025-12-30 22:42:18 +01:00
Mario Zechner
11b7f543ae
Refactor session manager: migration chain, validation, tests
...
- Add migrateV1ToV2/migrateToCurrentVersion for extensible migrations
- createSummaryMessage now takes timestamp from entry
- loadEntriesFromFile validates session header
- findMostRecentSession only returns valid session files (reads first 512 bytes)
- Remove ConversationEntry alias
- Fix mom context.ts TreeNode type
Tests:
- migration.test.ts: v1 migration, idempotency
- build-context.test.ts: 14 tests covering trivial, compaction, branches
- file-operations.test.ts: loadEntriesFromFile, findMostRecentSession
2025-12-30 22:42:18 +01:00
Mario Zechner
78dc48b273
Use short 8-char IDs for session entries
...
- Replace custom uuidv4() with native crypto.randomUUID()
- Entry IDs use first 8 hex chars with collision checking
- Session IDs stay full UUIDs (used in filenames)
- ~0.01 collisions per 10k entries, retry handles it
2025-12-30 22:42:17 +01:00
Mario Zechner
d0123b021b
Fix --session flag to use provided filename
...
When --session path was provided for a non-existent file, _initNewSession() was overwriting the path with an auto-generated one. Now it only generates a filename if sessionFile wasn't already set.
2025-12-30 22:42:17 +01:00
Mario Zechner
7bb808da52
Fix SessionEntry type to exclude SessionHeader
...
- SessionEntry now only contains conversation entries (messages, compaction, etc.)
- SessionHeader is separate, not part of SessionEntry
- FileEntry = SessionHeader | SessionEntry (for file storage)
- getEntries() filters out header, returns SessionEntry[]
- Added getHeader() for accessing session metadata
- Updated compaction and tests to not expect header in entries
- Updated mom package to use FileEntry for internal storage
2025-12-30 22:42:17 +01:00
Mario Zechner
baa1e10747
Fix API key priority and compaction bugs
...
- getEnvApiKey: ANTHROPIC_OAUTH_TOKEN now takes precedence over ANTHROPIC_API_KEY
- findCutPoint: Stop scan-backwards loop at session header (was decrementing past it causing null preparation)
- generateSummary/generateTurnPrefixSummary: Throw on stopReason=error instead of returning empty string
- Test files: Fix API key priority order, use keepRecentTokens=1 for small test conversations
2025-12-30 22:42:17 +01:00
Mario Zechner
ea7e8704aa
Session tree structure with id/parentId linking
...
- Add TreeNode base type with id, parentId, timestamp
- Add *Content types for clean input/output separation
- Entry types are now TreeNode & *Content intersections
- SessionManager assigns id/parentId on save, tracks leafId
- Add migrateSessionEntries() for v1 to v2 conversion
- Migration runs on load, rewrites file
- buildSessionContext() uses tree traversal from leaf
- Compaction returns CompactionResult (content only)
- Hooks return compaction content, not full entries
- Add firstKeptEntryId to before_compact hook event
- Update mom package for tree fields
- Better error messages for compaction failures
2025-12-30 22:42:17 +01:00
paulbettner
aef3e27715
tui: coalesce sequential status messages (+ tests)
2025-12-29 20:38:05 -05:00
Pratham Dubey
15492ef25b
Fix edit tool failing on Windows due to CRLF line endings
...
Normalize line endings to LF before matching, restore original style on write.
Files with CRLF now match when LLMs send LF-only oldText.
Fixes #355
2025-12-30 02:32:16 +05:30
Mario Zechner and GitHub
fef50995ed
Merge pull request #346 from ronyrus/main
...
Improve error message when `apiKey` or `model` are absent
2025-12-29 13:38:21 +01:00
Mario Zechner and GitHub
c7f7511f5a
Merge pull request #349 from Cursivez/fix/clickable-oauth-login-link
...
fix: Make OAuth login URL clickable in terminal
2025-12-29 13:34:33 +01:00
Armin Ronacher
6450a1c638
Fix /copy after aborts
2025-12-29 11:54:45 +01:00
Cursivez
3326d927ea
fix: make OAuth login URL clickable in terminal
...
Use OSC 8 hyperlink escape sequence to show 'Click here to login'
as a clickable link instead of displaying the raw URL which spans
multiple lines and is hard to click in terminals (especially WSL).
2025-12-29 13:45:11 +08:00
Rony Kelner
d2a160eb79
Improve error message when apiKey or model are absent
2025-12-29 10:39:04 +09:00
Duncan Ogilvie
c826183dfa
Add enabledModels to settings.json
2025-12-27 13:53:21 +01:00
Daniel Nouri
66309f4949
fix: Use bash instead of sh on Unix systems
...
The bash tool is named "bash" and described as executing bash commands,
but was using sh on Unix. On many distros (Ubuntu, Debian, Alpine, etc.),
/bin/sh is a POSIX-only shell that doesn't support bash syntax like [[ ]],
arrays, or here-strings. This caused the LLM to write bash syntax that
failed, wasting tokens on rewrites.
Now prefers /bin/bash on Unix, falling back to sh only if bash isn't found.
2025-12-26 23:12:57 +01:00
Mario Zechner
1c82a15c0b
Add automatic session migration for v0.30.0 bug
...
- Create migrations.ts with consolidated migrations
- Move auth migration from AuthStorage.migrateLegacy() to migrations.ts
- Add migrateSessionsFromAgentRoot() to fix misplaced sessions
- Sessions in ~/.pi/agent/*.jsonl are auto-migrated on startup
fixes #320
2025-12-26 03:24:49 +01:00
Mario Zechner
a37aff3761
Release v0.30.1
...
fixes #320
2025-12-26 03:13:37 +01:00
Mario Zechner
63a4d9dede
Fix custom system prompts missing context, skills, date/time, cwd
...
fixes #321
2025-12-26 03:06:10 +01:00
Kao Félix
1148beed4c
fix: use consistent model comparison including provider
2025-12-25 22:10:08 +01:00
Mario Zechner and scutifer
b3b78ac97a
feat(coding-agent): Add --session-dir flag for custom session directory
...
- Add --session-dir CLI flag to specify custom session directory
- SessionManager API: second param of create(), continueRecent(), list(), open()
changed from agentDir to sessionDir (direct directory, no cwd encoding)
- When omitted, uses default (~/.pi/agent/sessions/<encoded-cwd>/)
- --session now derives sessionDir from file's parent if --session-dir not provided
- list() validates session header before processing files
- Closes #313
Co-authored-by: scutifer <scutifer@users.noreply.github.com >
2025-12-25 20:27:41 +01:00
Mario Zechner and GitHub
671e7375fa
Merge pull request #315 from mitsuhiko/model-switcher
...
Reverse model switching and binding for dialog
2025-12-25 18:33:42 +01:00
Mario Zechner
c7bbeda1af
Merge branch 'fix-311'
2025-12-25 18:08:59 +01:00
Mario Zechner
83512fbf71
Fix jiti alias for typebox subpath imports in custom tools/hooks
...
fixes #311
2025-12-25 18:07:42 +01:00
Armin Ronacher
0911a426ad
Reverse model switching and binding for dialog
2025-12-25 18:07:36 +01:00
Mario Zechner
90832f945b
Auto-load SYSTEM.md as custom system prompt
...
Closes #309
2025-12-25 18:04:22 +01:00
Mario Zechner and GitHub
ea45015750
Add /settings command with unified settings menu ( #312 )
...
* Add /settings command with unified settings menu
- Add SettingsList component to tui package with support for:
- Inline value cycling (Enter/Space toggles)
- Submenus for complex selections
- Selection preservation when returning from submenu
- Add /settings slash command consolidating:
- Auto-compact (toggle)
- Show images (toggle)
- Queue mode (cycle)
- Hide thinking (toggle)
- Collapse changelog (toggle)
- Thinking level (submenu)
- Theme (submenu with preview)
- Update AGENTS.md to clarify no inline imports rule
Fixes #310
* Add /settings to README slash commands table
* Remove old settings slash commands, consolidate into /settings
- Remove /thinking, /queue, /theme, /autocompact, /show-images commands
- Remove unused selector methods and imports
- Update README references to use /settings
2025-12-25 15:39:42 +01:00
Mario Zechner
55da234db5
Add /settings command with unified settings menu
...
- Add SettingsList component to tui package with support for:
- Inline value cycling (Enter/Space toggles)
- Submenus for complex selections
- Selection preservation when returning from submenu
- Add /settings slash command consolidating:
- Auto-compact (toggle)
- Show images (toggle)
- Queue mode (cycle)
- Hide thinking (toggle)
- Collapse changelog (toggle)
- Thinking level (submenu)
- Theme (submenu with preview)
- Update AGENTS.md to clarify no inline imports rule
Fixes #310
2025-12-25 15:35:06 +01:00
Mario Zechner
504d0253f6
Rename /clear to /new, update hook events to before_new/new
...
Closes #305 - took direct rename approach instead of alias system
Thanks @mitsuhiko for the nudge!
2025-12-25 04:15:10 +01:00
Mario Zechner
c76d62be8e
Add removeRuntimeApiKey to AuthStorage
2025-12-25 03:57:20 +01:00
Mario Zechner
aa8f7029e1
Refactor OAuth/API key handling: AuthStorage and ModelRegistry
...
- Add AuthStorage class for credential storage (auth.json)
- Add ModelRegistry class for model management with API key resolution
- Add discoverAuthStorage() and discoverModels() discovery functions
- Add migration from legacy oauth.json and settings.json apiKeys to auth.json
- Remove configureOAuthStorage, defaultGetApiKey, findModel, discoverAvailableModels
- Remove apiKeys from Settings type and SettingsManager methods
- Rename getOAuthPath to getAuthPath
- Update SDK, examples, docs, tests, and mom package
Fixes #296
2025-12-25 03:48:36 +01:00
Mario Zechner
6b72cdab81
WIP: Add auth-storage.ts for credential management
...
- AuthStorage class for reading/writing auth.json
- Supports both api_key and oauth credential types
- getApiKey() priority: auth.json api_key > auth.json oauth > env var
2025-12-25 01:23:45 +01:00
Mario Zechner
d69c15f322
WIP: Rename model-config.ts to models-json.ts
...
- loadCustomModels now takes file path instead of agentDir
2025-12-25 01:15:17 +01:00
Armin Ronacher and Mario Zechner
241810afd8
Skip over exact duplicate skills
2025-12-24 22:45:19 +01:00
Mario Zechner
b244b6d41b
Fix model selector not showing models with settings.json API keys
...
Fixes #295
2025-12-24 21:23:44 +01:00
Mario Zechner
910c8cbee1
Release v0.27.8 - OAuth takes priority over settings.json API keys
2025-12-24 20:52:22 +01:00
Mario Zechner
54abb5d7ff
Improve compaction hooks: add signal, no timeout, SessionManager cleanup, docs
2025-12-24 13:54:05 +01:00
Mario Zechner
e9c20357e7
Add previousSummary to before_compact hook event
2025-12-24 12:47:12 +01:00
Mario Zechner
277fd22d5f
Improve before_compact hook: add messagesToKeep, replace apiKey with resolveApiKey
2025-12-24 12:41:22 +01:00
Mario Zechner
c5ffdc14e9
Add resolveApiKey to before_compact hook event
2025-12-24 12:28:51 +01:00
Mario Zechner
5652df8a89
Add syntax highlighting to HTML export using highlight.js
2025-12-24 12:13:56 +01:00
scutifer and Mario Zechner
78cf2bfc0b
feat: Improve HTML export with markdown rendering and theme support
...
- Render markdown server-side using marked (tables, headings, code blocks, etc.)
- Honor user's chosen theme (light/dark) with appropriate color defaults
- Add image rendering for user messages
- Style code blocks with TUI-like ```language markers
2025-12-24 12:13:15 +01:00
Nico Bailon and GitHub
4f36556cc8
Add before_compact hook event ( closes #281 ) ( #285 )
...
* Add before_compact hook event (closes #281 )
* Add compact hook event and documentation
- Add compact event that fires after compaction completes
- Update hooks.md with lifecycle diagram, field docs, and example
- Add CHANGELOG entry
- Add comprehensive test coverage (10 tests) for before_compact and compact events
- Tests cover: event emission, cancellation, custom entry, error handling, multiple hooks
2025-12-24 11:26:29 +01:00
Mario Zechner
538a257b58
Fix symlinked skill directories not being discovered
...
Release v0.27.4
2025-12-24 03:32:54 +01:00
Mario Zechner
ece66335e8
List all provider keys in README settings example
2025-12-24 02:42:41 +01:00
Mario Zechner
9d5ba8563d
Use injected resolveApiKey in AgentSession for settings.json support
2025-12-24 02:35:42 +01:00
Mario Zechner
26719278e2
Add API keys in settings.json, fixes #295
2025-12-24 02:11:17 +01:00
Mario Zechner
f956a584b3
Allow startup without API keys, fixes #288
2025-12-24 01:52:59 +01:00
scutifer and GitHub
3d86955731
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
Aliou Diallo and GitHub
d3b8a702b9
docs: fix outdated custom tools paths and add missing header shortcut ( #283 )
...
* docs: fix custom tools example paths to use index.ts structure
* fix: add missing ctrl+g shortcut to startup header
* docs: fix /session -> /resume for session switching references
2025-12-23 03:29:31 +01:00