Commit graph

1205 commits

Author SHA1 Message Date
Mario Zechner
e841942377 Use CompactionResult type for hook compaction return value
- Import CompactionResult in hooks/types.ts
- Replace inline type with CompactionResult for SessionEventResult.compaction
- Add labels feature to changelog
2025-12-30 22:42:18 +01:00
Mario Zechner
9e68a59fed Add label support for session entries
- Add LabelEntry type with targetId and label (string | undefined)
- Add labelsById map built on load via linear scan
- Add getLabel(id) and appendLabelChange(targetId, label) methods
- Add label field to SessionTreeNode, populated by getTree()
- Update createBranchedSession to preserve labels for entries on path
- Labels are ignored by buildSessionContext (not sent to LLM)
- Add comprehensive tests for label functionality
2025-12-30 22:42:18 +01:00
Mario Zechner
6af547afd9 Version updates 2025-12-30 22:42:18 +01:00
Mario Zechner
898607f742 Update session-tree-plan.md with remaining work 2025-12-30 22:42:18 +01:00
Mario Zechner
6f94e24629 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
beb70f126d 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
95312e00bb 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
77595b97f9 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
9478a3c1f5 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
251fea752c 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
c58d5f20a4 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
Mario Zechner
04a764742e
Merge pull request #358 from default-anton/migrate-glm-4.7-to-openai
Migrate zai provider from Anthropic to OpenAI-compatible API
2025-12-30 13:44:24 +01:00
Mario Zechner
c214a33405
Merge pull request #360 from prathamdby/fix/edit-crlf-windows
Fix edit tool failing on Windows due to CRLF line endings
2025-12-29 23:28:55 +01:00
Pratham Dubey
8c43a9fbc8 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
Anton Kuzmenko
0250b7ac03 Migrate zai provider from Anthropic to OpenAI-compatible API
- Migrate glm-4.5, glm-4.5-air, glm-4.5-flash, glm-4.6, glm-4.7 from anthropic-messages to openai-completions API
- Updated baseUrl from https://api.z.ai/api/anthropic to https://api.z.ai/api/coding/paas/v4
- Added compat setting to disable developer role for zai models
- Filter empty text blocks in openai-completions to avoid zai API validation errors
- Fixed zai provider tests to use OpenAI-style options (reasoningEffort)
2025-12-29 11:54:10 -08:00
Mario Zechner
65fb9116fb
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
557af13042
Merge pull request #344 from default-anton/feature/zai-openai-migration
Migrate zai provider from Anthropic to OpenAI-compatible API
2025-12-29 13:37:43 +01:00
Mario Zechner
193559bc65
Merge pull request #348 from ronyrus/mom-use-auth-json
make mom fetch apiKey from `authStorage`
2025-12-29 13:35:39 +01:00
Mario Zechner
8ced1131c0
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
Mario Zechner
723d467436
Merge pull request #351 from mitsuhiko/fix-copy
Fix /copy after aborts
2025-12-29 13:33:38 +01:00
Armin Ronacher
e30c4e30cb Fix /copy after aborts 2025-12-29 11:54:45 +01:00
Cursivez
d42a3d71fe 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
9bcfab3863 make mom fetch apiKey from authStorage instead of env vars 2025-12-29 12:50:43 +09:00
Rony Kelner
47b11bf798 Improve error message when apiKey or model are absent 2025-12-29 10:39:04 +09:00
Anton Kuzmenko
88d693cc00 test: add thinkingBudgetTokens parameter to thinking mode tests 2025-12-28 16:33:25 -08:00
Anton Kuzmenko
31cbbd211c fix: update zAI models to use anthropic API and filter empty thinking blocks in messages 2025-12-28 16:31:32 -08:00
Anton Kuzmenko
e9c6d95e6b Migrate zai provider from Anthropic to OpenAI-compatible API
- Change all zai models from anthropic-messages to openai-completions API
- Update baseUrl from https://api.z.ai/api/anthropic to https://api.z.ai/api/coding/paas/v4
- Add compat setting to disable developer role for zai
- Update zai provider tests to use OpenAI-style options (reasoningEffort instead of thinkingEnabled/thinkingBudgetTokens)
- Enable previously disabled thinking and image input tests for zai models
2025-12-28 13:37:34 -08:00
Anton Kuzmenko
93ea8298ab fix: update zai model API and baseUrl in generate-models script 2025-12-28 13:29:36 -08:00
Mario Zechner
c193ef74d2
Merge pull request #332 from mrexodia/fix-models-sorting
Make model generation deterministic by sorting providers and models
2025-12-27 18:36:24 +01:00
Mario Zechner
9b1e00a814
Merge pull request #331 from mrexodia/enabled-models
Add `enabledModels` to `settings.json`
2025-12-27 18:35:11 +01:00
Duncan Ogilvie
bf6da8c72f Make model generation deterministic by sorting providers and models 2025-12-27 13:58:51 +01:00
Duncan Ogilvie
9e6282e3dd Add enabledModels to settings.json 2025-12-27 13:53:21 +01:00
Mario Zechner
04fa79ebe0
Merge pull request #328 from dnouri/fix/use-bash-on-unix
fix: Use bash instead of sh on Unix systems
2025-12-27 01:03:58 +01:00
Daniel Nouri
8fc0610a53 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
ad10e2308e Update extension-loading.md with install/remove/update commands
- pi install <type> <source> (global default, -p for project)
- pi remove <type> <name>
- pi update [types...]
- Install adds to settings.json + installs to disk
- Global is default, -p/--project for project-local
2025-12-26 20:51:15 +01:00
Mario Zechner
31294e4749 Add extension loading design doc
Unified system for loading hooks, tools, skills, and themes from:
- Local files and directories
- npm packages (npm:pkg@version)
- Git repositories (git:url@tag or git:url#branch)

Includes filtering, atomic installation, and settings hierarchy.
2025-12-26 20:35:04 +01:00
Mario Zechner
bd276e6931 Add empty Unreleased section 2025-12-26 03:26:49 +01:00
Mario Zechner
0e8173af00 Release v0.30.2 2025-12-26 03:25:55 +01:00
Mario Zechner
cb6310e159 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
fa946c68fc Add session migration script for #320 2025-12-26 03:15:46 +01:00
Mario Zechner
7be4d52635 Add empty Unreleased section to changelog 2025-12-26 03:14:27 +01:00
Mario Zechner
9dcb0bdba4 Release v0.30.1
fixes #320
2025-12-26 03:13:37 +01:00
Mario Zechner
fbfdeb2c2e Fix custom system prompts missing context, skills, date/time, cwd
fixes #321
2025-12-26 03:06:10 +01:00
Mario Zechner
9652072f20
Merge pull request #319 from kaofelix/main
Use consistent model comparison including provider everywhere
2025-12-26 02:58:26 +01:00
Mario Zechner
3239a4a11a Add session version field and migrate-on-load strategy 2025-12-25 22:52:04 +01:00
Mario Zechner
013b6814e4 Clarify compaction in tree format: marker in chain, not a branch 2025-12-25 22:49:26 +01:00
Kao Félix
a7efe3d4c1 fix: use consistent model comparison including provider 2025-12-25 22:10:08 +01:00
Mario Zechner
64e7c80c7e Update session tree design to use UUIDs instead of indices 2025-12-25 21:19:02 +01:00
Mario Zechner
351faef604 Add session tree format design doc 2025-12-25 21:06:44 +01:00
Mario Zechner
6d97d212d5 Release v0.30.0 2025-12-25 20:35:14 +01:00