Commit graph

61 commits

Author SHA1 Message Date
Mario Zechner
3b8d0a8921 feat(coding-agent): add resources_discover hook 2026-02-01 02:20:35 +01:00
Mario Zechner
50c8323590 feat(coding-agent): package deduplication and collision detection
- Package deduplication: same package in global+project, project wins
- Collision detection for skills, prompts, and themes with ResourceCollision type
- PathMetadata tracking with parent directory lookup for file paths
- Display improvements: section headers, sorted groups, accent colors for packages
- pi list shows full paths below package names
- Extension loader discovers files in directories without index.ts
- In-memory SettingsManager properly tracks project settings

fixes #645
2026-01-24 00:35:19 +01:00
Mario Zechner
b846a4bfcf feat(coding-agent): ResourceLoader, package management, and /reload command (#645)
- Add ResourceLoader interface and DefaultResourceLoader implementation
- Add PackageManager for npm/git extension sources with install/remove/update
- Add session.reload() and session.bindExtensions() APIs
- Add /reload command in interactive mode
- Add CLI flags: --skill, --theme, --prompt-template, --no-themes, --no-prompt-templates
- Add pi install/remove/update commands for extension management
- Refactor settings.json to use arrays for skills, prompts, themes
- Remove legacy SkillsSettings source flags and filters
- Update SDK examples and documentation for ResourceLoader pattern
- Add theme registration and loadThemeFromPath for dynamic themes
- Add getShellEnv to include bin dir in PATH for bash commands
2026-01-22 13:49:38 +01:00
Mario Zechner
f0fd0a7d6a fix(mom): use coding-agent SessionManager instead of custom MomSessionManager
Removes MomSessionManager which was missing methods expected by AgentSession
(appendMessage, getBranch, etc.), causing runtime crashes.

Now uses the standard SessionManager from coding-agent with a fixed context.jsonl
path per channel. The syncLogToSessionManager function handles syncing messages
from log.jsonl using SessionManager's public API.

Ref #595
2026-01-11 04:03:42 +01:00
Mario Zechner
3ae02a6849 feat(coding-agent): complete steer()/followUp() migration
- Update settings-manager with steeringMode/followUpMode (migrates old queueMode)
- Update sdk.ts to use new mode options
- Update settings-selector UI to show both modes
- Add Alt+Enter keybind for follow-up messages
- Update RPC API: steer/follow_up commands, set_steering_mode/set_follow_up_mode
- Update rpc-client with new methods
- Delete dead code: queue-mode-selector.ts
- Update tests for new API
- Update mom/context.ts stubs
- Update web-ui example
2026-01-03 00:13:25 +01:00
Mario Zechner
c86f2a0136 Fix rebase issues: regenerate models, fix mom agent API 2025-12-30 22:42:25 +01:00
Mario Zechner
6ddc7418da WIP: Major cleanup - move Attachment to consumers, simplify agent API
- Removed Attachment from agent package (now in web-ui/coding-agent)
- Agent.prompt now takes (text, images?: ImageContent[])
- Removed transports from web-ui (duplicate of agent package)
- Updated coding-agent to use local message types
- Updated mom package for new agent API

Remaining: Fix AgentInterface.ts to compose UserMessageWithAttachments
2025-12-30 22:42:20 +01:00
Mario Zechner
a055fd4481 WIP: Refactor agent package - not compiling
- Renamed AppMessage to AgentMessage throughout
- New agent-loop.ts with AgentLoopContext, AgentLoopConfig
- Removed transport abstraction, Agent now takes streamFn directly
- Extracted streamProxy to proxy.ts utility
- Removed agent-loop from pi-ai (now in agent package)
- Updated consumers (coding-agent, mom) for AgentMessage rename
- Tests updated but some consumers still need migration

Known issues:
- AgentTool, AgentToolResult not exported from pi-ai
- Attachment not exported from pi-agent-core
- ProviderTransport removed but still referenced
- messageTransformer -> convertToLlm migration incomplete
- CustomMessages declaration merging not working properly
2025-12-30 22:42:20 +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
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
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
Rony Kelner
9bcfab3863 make mom fetch apiKey from authStorage instead of env vars 2025-12-29 12:50:43 +09:00
Mario Zechner
54018b6cc0 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
705ba5d4f2 Improve compaction hooks: add signal, no timeout, SessionManager cleanup, docs 2025-12-24 13:54:05 +01:00
Mario Zechner
86cfe6a436 Remove unused SessionHeader import from mom/context.ts 2025-12-22 02:52:18 +01:00
Mario Zechner
184c648334 Fix session persistence: flush all buffered entries on first assistant message
- SessionManager: add flushed flag, _persist() flushes all entries when first assistant seen
- SessionManager: reset() now creates session header
- MomSessionManager: same pattern, remove pendingEntries/sessionInitialized/startSession/shouldInitializeSession
2025-12-22 02:51:56 +01:00
Mario Zechner
0faadfcd00 Fix session-manager simplification issues
- Remove unused inspector import from session-manager.ts
- Remove dead code in _persist()
- Update tests for simplified SessionHeader
- Update mom context.ts: remove unused AgentState import, fix startSession(), rename isEnabled to isPersisted
2025-12-22 02:43:38 +01:00
Mario Zechner
d5fd685901 Enable more biome lints and fix things 2025-12-21 22:56:20 +01:00
Nico Bailon
17cadcc046 fix: send Slack image attachments inline to LLM 2025-12-20 11:13:43 -08:00
Mario Zechner
05b7b81338 Skills standard compliance
Implement Agent Skills standard (https://agentskills.io/specification):
- Validate name (must match parent dir, lowercase, max 64 chars)
- Validate description (required, max 1024 chars)
- Warn on unknown frontmatter fields
- Warn on name collisions (keep first)
- Change prompt format to XML structure
- Remove {baseDir} placeholder (use relative paths)
- Add tests and update documentation

fixes #231
2025-12-19 00:11:39 +01:00
Mario Zechner
27b7340d18 mom: fix skill paths to use container paths in system prompt
Translate host paths to container paths (/workspace/...) so mom can
read skill files from inside the Docker container.
2025-12-13 01:10:46 +01:00
Mario Zechner
e707ac4cd0 coding-agent, mom: add skills API export and mom skills auto-discovery
coding-agent:
- Export loadSkillsFromDir, formatSkillsForPrompt, and related types
- Refactor skills.ts to expose public API

mom:
- Add skills auto-discovery from workspace/skills and channel/skills
- Fix skill loading to use host paths (not Docker container paths)
- Update README and system prompt with SKILL.md format docs
2025-12-13 00:56:10 +01:00
Mario Zechner
f1451fd8f0 mom: fix [SILENT] to delete thread messages too
Track all thread message timestamps during a run. When response is
[SILENT], delete all thread messages before deleting the main message.
This prevents the 'This message was deleted' tombstone in Slack.
2025-12-12 22:56:56 +01:00
Mario Zechner
8ba6aa6627 mom: add [SILENT] response marker for periodic events
When mom responds with just [SILENT], the status message is deleted
and nothing is posted to Slack. Useful for periodic events that check
for activity but find nothing to report.
2025-12-12 22:50:12 +01:00
Mario Zechner
d6809328da mom: add events system for scheduled wake-ups
- Three event types: immediate, one-shot, periodic (cron)
- Events are JSON files in workspace/events/
- EventsWatcher with fs.watch, 100ms debounce
- Queue integration via SlackBot.enqueueEvent() (max 5)
- Fix setTyping race condition causing duplicate messages
- System prompt documents events for mom
- Design doc in docs/events.md
- Add croner dependency for cron scheduling
2025-12-12 22:45:34 +01:00
Mario Zechner
c6a4c1da95 Release v0.18.8 2025-12-12 11:30:11 +01:00
Mario Zechner
80a04fb1aa Release v0.18.7 2025-12-12 11:15:26 +01:00
Mario Zechner
dba2674681 Release v0.18.6 2025-12-12 10:53:53 +01:00
Mario Zechner
44e9b1c8e9 Release v0.18.5 2025-12-12 10:00:57 +01:00
Mario Zechner
e3576fe016 mom: fix attachment downloads - pass store to SlackBot, process files, use absolute paths 2025-12-11 23:55:49 +01:00
Mario Zechner
71b776e290 mom: add context usage to thread summary, update docs
- Usage summary now shows context tokens vs model context window
- Updated CHANGELOG.md with all recent changes
- Updated README.md with new file structure (log.jsonl/context.jsonl)
2025-12-11 20:24:05 +01:00
Mario Zechner
99fe4802ef mom: rewrite message handling - log.jsonl and context.jsonl sync
- log.jsonl is source of truth, context.jsonl syncs from it at run start
- Backfill fetches missing messages from Slack API on startup
- Messages sent while mom is busy are logged and synced on next run
- Channel chatter (no @mention) logged but doesn't trigger processing
- Pre-startup messages (replayed by Slack) logged but not processed
- Stop command executes immediately, not queued
- Session header written immediately on new session creation
- Deduplicate messages by timestamp
- Strip @mentions from backfilled messages
- Remove old slack.ts and main.ts, rename *-new.ts versions
2025-12-11 20:13:29 +01:00
Mario Zechner
e513127b3b mom: fix duplicate bot response logging, remove debug logs
- Remove bot response logging from agent.ts (already done in ctx.respond)
- Remove all debug console.log statements
- Clean up unused store parameter
2025-12-11 13:39:32 +01:00
Mario Zechner
cc71c0a49e mom: fix duplicate logging
- Remove user message logging from agent.ts (Slack handler already logs it)
- Add excludeTimestamp param to syncFromLog to skip current @mention
- Sync happens once before each prompt with current message excluded
2025-12-11 13:26:45 +01:00
Mario Zechner
5a231abe4c mom: remove last_prompt.txt debug file (context.jsonl is source of truth) 2025-12-11 13:22:59 +01:00
Mario Zechner
ca23ade9f8 mom: sync user messages from log.jsonl to context.jsonl before each agent run
- Ensures channel chatter and backfilled messages are in context
- Syncs on session creation and before each subsequent run
- User messages formatted as '[username]: text' in context
2025-12-11 13:20:40 +01:00
Mario Zechner
3f6db8e99c mom: refactor to use AgentSession for context management
- Export AgentSession, SessionManager, SettingsManager, compaction from coding-agent
- Create MomSessionManager for channel-based context.jsonl storage
- Create MomSettingsManager for mom-specific settings
- Refactor agent.ts to use AgentSession instead of ephemeral Agent
- Split logging: tool results go to context.jsonl, human messages to log.jsonl
- Enable auto-compaction and overflow detection from coding-agent

Part of #115
2025-12-11 13:09:01 +01:00
Mario Zechner
2a0f239288 mom: remove dynamic timestamp from system prompt for better cache hits 2025-12-11 12:26:59 +01:00
Mario Zechner
02c7f9ea51 Port truncation logic from coding-agent to mom
- Add truncate.ts with 2000 lines / 50KB limits
- Update bash tool with tail truncation and temp file output
- Update read tool with head truncation and offset hints
- Remove redundant context history truncation (tools already provide actionable hints)

fixes #155
2025-12-09 16:05:08 +01:00
Mario Zechner
029a04c43b fix(mom): clarify attach tool only works with /workspace/ files 2025-12-05 02:38:11 +01:00
Mario Zechner
e1d3c2b76e fix(mom): handle Slack msg_too_long errors gracefully
- Add try/catch to all Slack API calls in promise chain
- Truncate main channel messages at 35K with elaboration note
- Truncate thread messages at 20K
- Prevents process crash on long messages
2025-12-04 23:39:17 +01:00
Mario Zechner
c7585e37c9 Release v0.12.10 2025-12-04 20:51:57 +01:00
Mario Zechner
706554a5d3 fix(mom): private channel messages not being logged
- Add message.groups to required bot events in README
- Add groups:history and groups:read to required scopes in README
- app_mention handler now logs messages directly instead of relying on message event
- Add deduplication in ChannelStore.logMessage() to prevent double-logging
- Remove redundant current message append in agent.ts (already in log)
2025-12-04 12:24:29 +01:00
Mario Zechner
f02194296d feat(mom): backfill missed messages on startup using conversations.history API
- Add getLastTimestamp() to ChannelStore to read last ts from log.jsonl
- Add backfillChannel() to fetch up to 3 pages (3000 messages) per channel
- Add backfillAllChannels() called in start() before socket connection
- Include mom's own messages (as bot) and user messages, exclude other bots
- Process attachments from backfilled messages
- Add logging: logBackfillStart, logBackfillChannel, logBackfillComplete
- Warn if attachment missing name instead of failing

fixes #103
2025-12-03 22:05:13 +01:00
Mario Zechner
75bb14cc4d fix(mom): include triggering message in context
Fix race condition where app_mention event fires before message event
logs to log.jsonl, causing the user's triggering message to be missing
from the agent's context. Now append the current message directly from
ctx.message to recentMessages.
2025-12-01 11:56:40 +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
5fcdf0cfd8 feat(mom): add arrow prefix to tool labels for visual distinction
Closes #65
2025-11-27 14:11:08 +01:00